user1067257
user1067257

Reputation: 453

Convert List to Pandas Timeseries

I have a list of python dates that looks like this:

2012-12-14
2013-02-03
2013-03-24
2012-01-08
2012-11-30
2012-04-10
2012-01-01

How could I convert this list to a pandas time series object?

Upvotes: 3

Views: 4630

Answers (1)

Jeff
Jeff

Reputation: 128978

Just put your list where I have data.split('\n') - only needed because I copy/pasted your input

In [11]: Series(pd.to_datetime(data.split('\n')))
Out[11]: 
0   2012-12-14 00:00:00
1   2013-02-03 00:00:00
2   2013-03-24 00:00:00
3   2012-01-08 00:00:00
4   2012-11-30 00:00:00
5   2012-04-10 00:00:00
6   2012-01-01 00:00:00
dtype: datetime64[ns]

Upvotes: 4

Related Questions