File tree 2 files changed +18
-0
lines changed 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ def read_csv(
67
67
infer_datetime_format : bool = ...,
68
68
keep_date_col : bool = ...,
69
69
date_parser : Callable = ...,
70
+ date_format : str | Mapping [int | str , str ] | None = ...,
70
71
dayfirst : bool = ...,
71
72
cache_dates : bool = ...,
72
73
iterator : Literal [True ],
@@ -126,6 +127,7 @@ def read_csv(
126
127
infer_datetime_format : bool = ...,
127
128
keep_date_col : bool = ...,
128
129
date_parser : Callable = ...,
130
+ date_format : str | Mapping [int | str , str ] | None = ...,
129
131
dayfirst : bool = ...,
130
132
cache_dates : bool = ...,
131
133
iterator : bool = ...,
@@ -185,6 +187,7 @@ def read_csv(
185
187
infer_datetime_format : bool = ...,
186
188
keep_date_col : bool = ...,
187
189
date_parser : Callable = ...,
190
+ date_format : str | Mapping [int | str , str ] | None = ...,
188
191
dayfirst : bool = ...,
189
192
cache_dates : bool = ...,
190
193
iterator : Literal [False ] = ...,
Original file line number Diff line number Diff line change @@ -638,6 +638,21 @@ def test_types_read_csv() -> None:
638
638
tfr4 : TextFileReader = pd .read_csv (path , nrows = 2 , iterator = True )
639
639
tfr4 .close ()
640
640
641
+ df_dates = pd .DataFrame (data = {"col1" : ["2023-03-15" , "2023-04-20" ]})
642
+
643
+ with ensure_clean () as path :
644
+ df_dates .to_csv (path )
645
+
646
+ df26 : pd .DataFrame = pd .read_csv (
647
+ path , parse_dates = ["col1" ], date_format = "%Y-%m-%d"
648
+ )
649
+ df27 : pd .DataFrame = pd .read_csv (
650
+ path , parse_dates = ["col1" ], date_format = {"col1" : "%Y-%m-%d" }
651
+ )
652
+ df28 : pd .DataFrame = pd .read_csv (
653
+ path , parse_dates = ["col1" ], date_format = {1 : "%Y-%m-%d" }
654
+ )
655
+
641
656
642
657
def test_read_table ():
643
658
with ensure_clean () as path :
You can’t perform that action at this time.
0 commit comments