xref #10110
.astype(str)
on DatetimeIndex
to use call .format()
(Index method)- [ ] Add Series.dt.format()
accessor to call .format()
(#10110 does this with .strftime
)
Series.astype(str)
to call equiv of Series.dt.format()
for datetime64[ns]
dtypeRecently the ability to convert a datetimelike series to strings with astype(str)
was introduced (#9758 by @evanpw):
In [27]: pd.Series(pd.date_range('2012-01-01', periods=3))
Out[27]:
0 2012-01-01
1 2012-01-02
2 2012-01-03
dtype: datetime64[ns]
In [28]: pd.Series(pd.date_range('2012-01-01', periods=3)).astype(str)
Out[28]:
0 2012-01-01T01:00:00.000000000+0100
1 2012-01-02T01:00:00.000000000+0100
2 2012-01-03T01:00:00.000000000+0100
dtype: object
it would be nice if this also possible on a index (now you still get the same error as previously for a series):
In [29]: pd.date_range('2012-01-01', periods=3).astype(str)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-29-68a28f79c8e9> in <module>()
----> 1 pd.date_range('2012-01-01', periods=3).astype(str)
C:\Users\vdbosscj\Scipy\pandas-joris\pandas\tseries\index.py in astype(self, dty
pe)
692 return self.asi8.copy()
693 else: # pragma: no cover
--> 694 raise ValueError('Cannot cast DatetimeIndex to dtype %s' % d
type)
695
696 def _get_time_micros(self):
ValueError: Cannot cast DatetimeIndex to dtype |S0
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4