related #4147
Observe w/o tz:
In [46]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1")]).min()
Out[46]: Timestamp('2013-01-01 00:00:00', tz=None)
however w/ tz:
In [48]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")]).min()
Out[48]: NaT
strangely, max
works:
In [60]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")]).max()
Out[60]: Timestamp('2013-01-01 00:00:00-0500', tz='US/Eastern')
Comment From: jreback
this is the same reason as #4147 as these series are object dtype
Comment From: jreback
related - the string rep of this type of mixed series is wrong....
In [7]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")])
Out[7]:
0 NaN
1 2013-01-01 00:00:00-05:00
dtype: object
In [8]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")]).iloc[0]
Out[8]: NaT
In [9]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")]).iloc[1]
Out[9]: Timestamp('2013-01-01 00:00:00-0500', tz='US/Eastern')
Comment From: cancan101
@jreback The issue you refer to in regards to formatting of NaT
in an object array is caused by GenericArrayFormatter
taking in only one value for na_rep
which defaults to NaN
. When formatting, that value is used as:
if self.na_rep is not None and lib.checknull(x):
if x is None:
return 'None'
return self.na_rep
One option would be to add another argument nat_rep
.
Comment From: jorisvandenbossche
In the meantime, this works as expected:
In [9]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")])
Out[9]:
0 NaT
1 2013-01-01 00:00:00-05:00
dtype: datetime64[ns, US/Eastern]
In [10]: pd.Series([pd.NaT, pd.Timestamp("2013-1-1", tz="US/Eastern")]).min()
Out[10]: Timestamp('2013-01-01 00:00:00-0500', tz='US/Eastern')
probably since timezone aware datetime is now a proper dtype and no longer object