Skip to content

BUG: consistent datetime display format with < ms #10170 #10171

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

Merged
merged 1 commit into from
May 20, 2015

Conversation

jreback
Copy link
Contributor

@jreback jreback commented May 19, 2015

closes #10170

In [3]: Series(date_range('20130101 09:00:00',periods=5,freq='D'))
Out[3]: 
0   2013-01-01 09:00:00
1   2013-01-02 09:00:00
2   2013-01-03 09:00:00
3   2013-01-04 09:00:00
4   2013-01-05 09:00:00
dtype: datetime64[ns]

In [4]: Series(date_range('20130101 09:00:00',periods=5,freq='s'))
Out[4]: 
0   2013-01-01 09:00:00
1   2013-01-01 09:00:01
2   2013-01-01 09:00:02
3   2013-01-01 09:00:03
4   2013-01-01 09:00:04
dtype: datetime64[ns]

In [2]: s = Series(date_range('20130101 09:00:00',periods=5,freq='ms'))

In [3]: s.iloc[1] = np.nan

In [4]: s
Out[4]: 
0   2013-01-01 09:00:00.000
1                       NaT
2   2013-01-01 09:00:00.002
3   2013-01-01 09:00:00.003
4   2013-01-01 09:00:00.004
dtype: datetime64[ns]

In [6]: Series(date_range('20130101 09:00:00',periods=5,freq='us'))
Out[6]: 
0   2013-01-01 09:00:00.000000
1   2013-01-01 09:00:00.000001
2   2013-01-01 09:00:00.000002
3   2013-01-01 09:00:00.000003
4   2013-01-01 09:00:00.000004
dtype: datetime64[ns]

In [7]: Series(date_range('20130101 09:00:00',periods=5,freq='N'))
Out[7]: 
0   2013-01-01 09:00:00.000000000
1   2013-01-01 09:00:00.000000001
2   2013-01-01 09:00:00.000000002
3   2013-01-01 09:00:00.000000003
4   2013-01-01 09:00:00.000000004
dtype: datetime64[ns]

@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string labels May 19, 2015
@jreback jreback added this to the 0.17.0 milestone May 19, 2015
@jreback jreback force-pushed the dt_format branch 3 times, most recently from f6bff5c to 780840d Compare May 19, 2015 15:53
@jorisvandenbossche
Copy link
Member

Thanks!

Does it make sense to also have the 'milliseconds' resolution? (the third example above, so up to 3 decimals after the comma) instead of at once microsecond

@jreback
Copy link
Contributor Author

jreback commented May 19, 2015

@jorisvandenbossche fixed up for 'ms'. updated the top.

@jorisvandenbossche
Copy link
Member

Nice!

@jreback
Copy link
Contributor Author

jreback commented May 20, 2015

@jorisvandenbossche look ok?

@jorisvandenbossche
Copy link
Member

yes!

jorisvandenbossche added a commit that referenced this pull request May 20, 2015
BUG: consistent datetime display format with < ms #10170
@jorisvandenbossche jorisvandenbossche merged commit 0aceb38 into pandas-dev:master May 20, 2015
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.17.0, 0.16.2 Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display of a datetime column/index with both second and sub-second resolution
2 participants