Skip to content

Display of a datetime column/index with both second and sub-second resolution #10170

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Should a datetime column should use the same precision for all, padding with zeros, just like a float column does?

In [121]: df = pd.DataFrame({'datetime': pd.date_range('1/1/2000 09:00:00', freq="5ms",periods=10), 'float': np.arange(0,0.05,0.005)})

In [122]: df
Out[122]:
                    datetime  float
0        2000-01-01 09:00:00  0.000
1 2000-01-01 09:00:00.005000  0.005
2 2000-01-01 09:00:00.010000  0.010
3 2000-01-01 09:00:00.015000  0.015
4 2000-01-01 09:00:00.020000  0.020
5 2000-01-01 09:00:00.025000  0.025
6 2000-01-01 09:00:00.030000  0.030
7 2000-01-01 09:00:00.035000  0.035
8 2000-01-01 09:00:00.040000  0.040
9 2000-01-01 09:00:00.045000  0.045

so that the first row would show 2000-01-01 09:00:00.000000?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions