Skip to content

isnull not detecting NaT in PeriodIndex #9129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
unutbu opened this issue Dec 22, 2014 · 2 comments · Fixed by #9134
Closed

isnull not detecting NaT in PeriodIndex #9129

unutbu opened this issue Dec 22, 2014 · 2 comments · Fixed by #9134
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Period Period data type
Milestone

Comments

@unutbu
Copy link
Contributor

unutbu commented Dec 22, 2014

In [158]: x = pd.to_datetime([np.nan, '2000-1-1'])

In [159]: y = x.to_period(freq='m')

In [160]: y
Out[160]: 
<class 'pandas.tseries.period.PeriodIndex'>
[NaT, 2000-01]
Length: 2, Freq: M

In [161]: pd.isnull(x)
Out[161]: array([ True, False], dtype=bool)

In [162]: pd.isnull(y)
Out[162]: array([False, False], dtype=bool)

I think pd.isnull(y) should be returning array([True, False], dtype=bool).

@jreback
Copy link
Contributor

jreback commented Dec 22, 2014

hmm, must be taking an odd path

@jreback jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Period Period data type labels Dec 22, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 22, 2014
@jreback
Copy link
Contributor

jreback commented Dec 22, 2014

https://github.com/pydata/pandas/blob/master/pandas/core/common.py#L305 (this is done in several places)

maybe make a function

is_datetimelike(arr):
     return arr.dtype in _DATETIME_TYPE or isintance(arr, ABCPeriodIndex)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants