-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Description
The convert_objects(convert_dates='force') should really just to
to_datetime()....
In [1]: In [1]: data = """
...: ...: value date id
...: ...: 0 2 2013-3-1 a
...: ...: 1 3 2013-3-1 b
...: ...: 2 4 2013-3-1 c
...: ...: 3 5 nan d
...: ...: 4 6 2013-3-1 d
...: ...: """
In [2]: In [15]: df = pd.read_csv(StringIO(data[1:]),index_col=0,sep='\s+')
In [3]: df.dtypes
Out[3]:
...: float64
value float64
date object
id object
dtype: object
In [4]: In [24]: pd.to_datetime(df['date'])
Out[4]:
...: 2013-03-01 00:00:00
...: 2013-03-01 00:00:00
...: 2013-03-01 00:00:00
...: NaT
...: 2013-03-01 00:00:00
...: NaT
Name: date, dtype: datetime64[ns]
In [5]: df['date'].convert_objects(convert_dates=True)
Out[5]:
...: 2013-3-1
...: 2013-3-1
...: 2013-3-1
...: NaN
...: 2013-3-1
...: None
Name: date, dtype: object
Metadata
Metadata
Assignees
Labels
RefactorInternal refactoring of codeInternal refactoring of code