-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: read_csv: date_format #59557
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
Comments
… pandas/io/parsers/readers.py issue pandas-dev#59557
… pandas/io/parsers/readers.py issue pandas-dev#59557
Thanks for the report. Does this always result in a datetime, or can it result in a date and/or time? I think that would determine whether the documentation should be refined to say
Reports and contributions are welcome, this is not. |
Looks like the result is always a >>> from io import StringIO
>>> import pandas as pd
>>> pd.read_csv(StringIO(',A\n7/12/2024 5:40:41 PM,0\n7/12/2024 5:41:41 PM,0'), # date and time
parse_dates=True, index_col=0).index
DatetimeIndex(['2024-07-12 17:40:41', '2024-07-12 17:41:41'], dtype='datetime64[ns]', freq=None)
>>> pd.read_csv(StringIO(',A\n7/12/2024,0\n7/12/2024,0'), # date only
parse_dates=True, index_col=0).index
DatetimeIndex(['2024-07-12', '2024-07-12'], dtype='datetime64[ns]', freq=None)
>>> pd.read_csv(StringIO(',A\n5:40:41 PM,0\n5:41:41 PM,0'), # time only
parse_dates=True, index_col=0).index
DatetimeIndex(['2024-08-20 17:40:41', '2024-08-20 17:41:41'], dtype='datetime64[ns]', freq=None)
Sorry. No offense intended. I took it out. |
#59566) DOC: Clarify date_format usage in read_csv documentation specifically pandas/io/parsers/readers.py issue #59557 Co-authored-by: Matthew Roeschke <[email protected]>
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/dev/reference/api/pandas.read_csv.html
Documentation problem
When using
read_csv
, I came across aUserWarning: Could not infer format...
. I tried to resolve it by providing adate_format
, but the warning wouldn't go away. Then I realized that my problem was that I was providing specifically the date format but not the time format.The documentation for this parameter is confusing. It starts with what appear to be two alternate and contradictory definitions of the parameter:
parse_dates
."strftime
to parse time, e.g."%d/%m/%Y"
."Suggested fix for documentation
Say something like this:
"Format to use for parsing dates and/or times. Used in conjunction with
parse_dates
. Seestrftime
documentation for more information on choices..."The text was updated successfully, but these errors were encountered: