Skip to content

Commit

Permalink
Fixed ASV benchmark: format method disappeared from DateTimeIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Mar 8, 2024
1 parent e0ddfcb commit b09c641
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions asv_bench/benchmarks/strftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ def time_frame_date_to_str(self, nobs, tz_aware):
def time_frame_date_formatting_default(self, nobs, tz_aware):
self.data["d"].dt.strftime(date_format=None)

def time_frame_date_formatting_index_to_str(self, nobs, tz_aware):
self.data.index.astype(str)

def time_frame_date_formatting_index_default(self, nobs, tz_aware):
self.data.index.format()
self.data.index.strftime(date_format=None)

def time_frame_date_formatting_custom(self, nobs, tz_aware):
self.data["d"].dt.strftime(date_format="%Y---%m---%d")

def time_frame_date_formatting_index_custom(self, nobs, tz_aware):
self.data.index.format(date_format="%Y---%m---%d")
self.data.index.strftime(date_format="%Y---%m---%d")

def time_frame_datetime_to_str(self, nobs, tz_aware):
self.data["dt"].astype(str)
Expand All @@ -56,14 +59,17 @@ def time_frame_datetime_formatting_default_explicit(self, nobs, tz_aware):
def time_frame_datetime_formatting_default_with_float(self, nobs, tz_aware):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d %H:%M:%S.%f")

def time_frame_datetime_formatting_index_to_str(self, nobs, tz_aware):
self.data.set_index("dt").index.astype(str)

def time_frame_datetime_formatting_index_default(self, nobs, tz_aware):
self.data.set_index("dt").index.format()
self.data.set_index("dt").index.strftime()

def time_frame_datetime_formatting_custom(self, nobs, tz_aware):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d --- %H:%M:%S")

def time_frame_datetime_formatting_index_custom(self, nobs, tz_aware):
self.data.set_index("dt").index.format(date_format="%Y-%m-%d --- %H:%M:%S")
self.data.set_index("dt").index.strftime(date_format="%Y-%m-%d --- %H:%M:%S")

def time_frame_datetime_formatting_iso8601_map(self, nobs, tz_aware):
self.data["dt"].map(lambda timestamp: timestamp.isoformat())
Expand Down

0 comments on commit b09c641

Please sign in to comment.