Skip to content

PERF: DatetimeIndex constructor from list #48609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add asv
  • Loading branch information
lukemanley committed Sep 17, 2022
commit 88460553630b34cba67bbd406d62e317eb012b38
25 changes: 25 additions & 0 deletions asv_bench/benchmarks/ctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
MultiIndex,
Series,
Timestamp,
date_range,
)

from .pandas_vb_common import tm
Expand Down Expand Up @@ -121,4 +122,28 @@ def time_multiindex_from_iterables(self):
MultiIndex.from_product(self.iterables)


class DatetimeIndexConstructor:
def setup(self):

N = 100_000
dti = date_range("1900-01-01", periods=N)

self.list_of_timestamps = dti.tolist()
self.list_of_dates = dti.date.tolist()
self.list_of_datetimes = dti.to_pydatetime().tolist()
self.list_of_str = dti.strftime("%Y-%m-%d").tolist()

def time_from_list_of_timestamps(self):
DatetimeIndex(self.list_of_timstamps)

def time_from_list_of_dates(self):
DatetimeIndex(self.list_of_dates)

def time_from_list_of_datetimes(self):
DatetimeIndex(self.list_of_datetimes)

def time_from_list_of_str(self):
DatetimeIndex(self.list_of_str)


from .pandas_vb_common import setup # noqa: F401 isort:skip