Skip to content

smaller than microsecond timedelta64 Series are not saved correctly with to_csv #6783

Closed
@cpcloud

Description

@cpcloud
In [24]: x = Series(np.around(randn(10) * 100).astype('timedelta64[ns]'))

In [25]: x
Out[25]:
0   -00:00:00.000000
1    00:00:00.000000
2   -00:00:00.000000
3   -00:00:00.000000
4    00:00:00.000000
5   -00:00:00.000000
6   -00:00:00.000000
7   -00:00:00.000000
8   -00:00:00.000000
9   -00:00:00.000000
dtype: timedelta64[ns]

In [26]: x.values
Out[26]: array([-259,   31,  -49,  -41,  141,  -14, -111, -117,  -20,  -35], dtype='timedelta64[ns]')

In [27]: buf = StringIO()

In [28]: x.to_csv(buf)

In [29]: print(buf.getvalue())
0,-00:00:00.000000
1,00:00:00.000000
2,-00:00:00.000000
3,-00:00:00.000000
4,00:00:00.000000
5,-00:00:00.000000
6,-00:00:00.000000
7,-00:00:00.000000
8,-00:00:00.000000
9,-00: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