diff --git a/doc/source/v0.10.1.txt b/doc/source/v0.10.1.txt index 8aa2dad2b35a0..a2b99bf6c4174 100644 --- a/doc/source/v0.10.1.txt +++ b/doc/source/v0.10.1.txt @@ -14,6 +14,21 @@ API changes New features ~~~~~~~~~~~~ +Datetime64[ns] columns in a DataFrame (or a Series) allow the use of ``np.nan`` to indicate a nan value, in addition to the traditional ``NaT``, or not-a-time. This allows convenient nan setting in a generic way. Furthermore datetime64 columns are created by default, when using ``datetime.datetime`` or ``Timestamp`` objects, rather than default as object dtype. + +.. ipython:: python + + df = DataFrame(randn(6,2),date_range('20010102',periods=6),columns=['A','B']) + df['timestamp'] = Timestamp('20010103') + df + + # datetime64[ns] out of the box + df.get_dtype_counts() + + # use the traditional nan, which is mapped to NaT internally + df.ix[2:4,['A','timestamp']] = np.nan + df + HDFStore ~~~~~~~~ @@ -59,7 +74,7 @@ You can now store ``datetime64`` in data columns df_mixed = df.copy() df_mixed['datetime64'] = Timestamp('20010102') - df_mixed.ix[3:4,['A','B']] = np.nan + df_mixed.ix[3:4,['A','B','datetime64']] = np.nan store.append('df_mixed', df_mixed) df_mixed1 = store.select('df_mixed') diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 301ea9d28d001..4c3922d313684 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4287,9 +4287,9 @@ def applymap(self, func): applied : DataFrame """ - # if we have a dtype == 'M8[ns]', provide boxed values + # if we have a datetime64 type, provide boxed values def infer(x): - if x.dtype == 'M8[ns]': + if com.is_datetime64_dtype(x): x = lib.map_infer(x, lib.Timestamp) return lib.map_infer(x, func) return self.apply(infer)