File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,18 @@ def time_frame_date_formatting(self):
67
67
self .data .to_csv (self .fname , date_format = "%Y%m%d" )
68
68
69
69
70
+ class ToCSVDatetimeIndex (BaseIO ):
71
+
72
+ fname = "__test__.csv"
73
+
74
+ def setup (self ):
75
+ rng = date_range ("2000" , periods = 100_000 , freq = "S" )
76
+ self .data = DataFrame ({"a" : 1 }, index = rng )
77
+
78
+ def time_frame_date_formatting_index (self ):
79
+ self .data .to_csv (self .fname , date_format = "%Y-%m-%d %H:%M:%S" )
80
+
81
+
70
82
class ToCSVDatetimeBig (BaseIO ):
71
83
72
84
fname = "__test__.csv"
Original file line number Diff line number Diff line change @@ -589,6 +589,7 @@ Performance improvements
589
589
- Performance improvement in :meth: `Series.to_frame ` (:issue: `43558 `)
590
590
- Performance improvement in :meth: `Series.mad ` (:issue: `43010 `)
591
591
- Performance improvement in :func: `merge ` (:issue: `43332 `)
592
+ - Performance improvement in :func: `to_csv ` when index column is a datetime and is formatted (:issue: `39413 `)
592
593
- Performance improvement in :func: `read_csv ` when ``index_col `` was set with a numeric column (:issue: `44158 `)
593
594
- Performance improvement in :func: `concat ` (:issue: `43354 `)
594
595
-
Original file line number Diff line number Diff line change 26
26
StorageOptions ,
27
27
WriteBuffer ,
28
28
)
29
+ from pandas .util ._decorators import cache_readonly
29
30
30
31
from pandas .core .dtypes .generic import (
31
32
ABCDatetimeIndex ,
@@ -175,7 +176,7 @@ def _number_format(self) -> dict[str, Any]:
175
176
"decimal" : self .decimal ,
176
177
}
177
178
178
- @property
179
+ @cache_readonly
179
180
def data_index (self ) -> Index :
180
181
data_index = self .obj .index
181
182
if (
You can’t perform that action at this time.
0 commit comments