Skip to content

to_csv date_format including hh:mm:ss #10209

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

Closed
k-dahl opened this issue May 26, 2015 · 5 comments
Closed

to_csv date_format including hh:mm:ss #10209

k-dahl opened this issue May 26, 2015 · 5 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@k-dahl
Copy link

k-dahl commented May 26, 2015

Since 0.16.1 the to_csv output of a dataframe has started including hh:mm:ss with date_format strings like:

date_format='%d-%m-%Y'

Reverting back to 0.16.0 the date output was then formatted properly (without time).

@jreback
Copy link
Contributor

jreback commented May 26, 2015

You will have to be more specific and show an example. As this is as expected.

In [1]: pd.__version__
Out[1]: '0.16.1'

In [3]: DataFrame({'A' : pd.date_range('20130101',periods=5,freq='s')}).to_csv()
Out[3]: ',A\n0,2013-01-01 00:00:00\n1,2013-01-01 00:00:01\n2,2013-01-01 00:00:02\n3,2013-01-01 00:00:03\n4,2013-01-01 00:00:04\n'

you mean this (in 0.16.0)

In [9]: DataFrame({'A' : pd.date_range('20130101',periods=5,freq='s')}).to_csv(date_format='%Y-%m-%d')
Out[9]: ',A\n0,2013-01-01\n1,2013-01-01\n2,2013-01-01\n3,2013-01-01\n4,2013-01-01\n'

@jreback
Copy link
Contributor

jreback commented May 26, 2015

There were some changes to correct a number of bugs in date formatting. This looks like an untested path. Marking as a bug.

@jreback
Copy link
Contributor

jreback commented May 26, 2015

this is releated to #7791

@jreback jreback added Regression Functionality that used to work in a prior pandas version Output-Formatting __repr__ of pandas objects, to_string Difficulty Novice labels May 26, 2015
@jreback jreback added this to the 0.17.0 milestone May 26, 2015
@k-dahl
Copy link
Author

k-dahl commented May 26, 2015

Actually, date_format appears to be altogether ignored in 0.16.1 to_csv:

In [18]: pd.__version__
Out[18]: '0.16.1'

In [19]: pd.DataFrame({'A' : pd.date_range('20130101',periods=5,freq='s')}).to_csv(date_format='%d-%m-%Y')
Out[19]: ',A\n0,2013-01-01 00:00:00\n1,2013-01-01 00:00:01\n2,2013-01-01 00:00:02\n3,2013-01-01 00:00:03\n4,2013-01-01 00:00:04\n'

In [4]: pd.__version__
Out[4]: '0.16.0'

In [5]: pd.DataFrame({'A' : pd.date_range('20130101',periods=5,freq='s')}).to_csv(date_format='%d-%m-%Y')
Out[5]: ',A\n0,01-01-2013\n1,01-01-2013\n2,01-01-2013\n3,01-01-2013\n4,01-01-2013\n'

@jreback
Copy link
Contributor

jreback commented Jun 5, 2015

closed by #10247

@jreback jreback closed this as completed Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants