File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ def read_csv(
6767 infer_datetime_format : bool = ...,
6868 keep_date_col : bool = ...,
6969 date_parser : Callable = ...,
70+ date_format : str | Mapping [int | str , str ] | None = ...,
7071 dayfirst : bool = ...,
7172 cache_dates : bool = ...,
7273 iterator : Literal [True ],
@@ -126,6 +127,7 @@ def read_csv(
126127 infer_datetime_format : bool = ...,
127128 keep_date_col : bool = ...,
128129 date_parser : Callable = ...,
130+ date_format : str | Mapping [int | str , str ] | None = ...,
129131 dayfirst : bool = ...,
130132 cache_dates : bool = ...,
131133 iterator : bool = ...,
@@ -185,6 +187,7 @@ def read_csv(
185187 infer_datetime_format : bool = ...,
186188 keep_date_col : bool = ...,
187189 date_parser : Callable = ...,
190+ date_format : str | Mapping [int | str , str ] | None = ...,
188191 dayfirst : bool = ...,
189192 cache_dates : bool = ...,
190193 iterator : Literal [False ] = ...,
Original file line number Diff line number Diff line change @@ -638,6 +638,21 @@ def test_types_read_csv() -> None:
638638 tfr4 : TextFileReader = pd .read_csv (path , nrows = 2 , iterator = True )
639639 tfr4 .close ()
640640
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+
641656
642657def test_read_table ():
643658 with ensure_clean () as path :
You can’t perform that action at this time.
0 commit comments