We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
to_csv
date_format
PeriodArray
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
First reported in #51459
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
>>> import pandas as pd >>> data = pd.DataFrame(pd.period_range(start="2000-01-01", periods=1, freq="H")) >>> print(data.to_csv()) ,0 0,2000-01-01 00:00 1,2000-01-01 01:00 >>> print(data.to_csv(date_format="%Y-%m-%d___%H:%M:%S")) ,0 0,2000-01-01 00:00 1,2000-01-01 01:00 >>> print(data.set_index(0).to_csv(date_format="%Y-%m-%d___%H:%M:%S")) 0 2000-01-01___00:00:00 2000-01-01___01:00:00
to_csv does not take into account date_format for PeriodArrays that are normal columns the dataframe. Only PeriodIndex are correctly formatted.
PeriodIndex
The formatting should be right even if the period array is not the index
The text was updated successfully, but these errors were encountered:
Period
period_format
take
Sorry, something went wrong.
lia2710
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
First reported in #51459
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
to_csv
does not take into accountdate_format
forPeriodArray
s that are normal columns the dataframe. OnlyPeriodIndex
are correctly formatted.Expected Behavior
The formatting should be right even if the period array is not the index
Installed Versions
The text was updated successfully, but these errors were encountered: