Skip to content

COMPAT: NaT accessors #15782

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

Merged
merged 1 commit into from
Mar 27, 2017
Merged

COMPAT: NaT accessors #15782

merged 1 commit into from
Mar 27, 2017

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Mar 22, 2017

closes #15781

PR

In [1]: idx = DatetimeIndex(['1/1/2000', None, None, '1/4/2000'])

In [2]: idx.is_month_start
Out[2]: array([ True, False, False, False], dtype=bool)

In [3]: idx.is_leap_year
Out[3]: array([ True, False, False,  True], dtype=bool)

0.19.2

In [1]: idx = DatetimeIndex(['1/1/2000', None, None, '1/4/2000'])

In [3]: idx.is_month_start
Out[3]: array([  1.,  nan,  nan,   0.])

In [2]: idx.is_leap_year
Out[2]: array([ True, False, False,  True], dtype=bool)

mimics is_leap_year to return a boolean (inlcuding for NaT).

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timedelta Timedelta data type Datetime Datetime data dtype labels Mar 22, 2017
for field in self._bool_accessors:

result = getattr(NaT, field)
assert not result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert result is False
In the bare assert style for pytest, I find that a bit clearer if you are explicitly testing for False, and in this case, more importantly, otherwise 0 would pass the test (eg if for some reason the result if converted to float which is what happens in the current code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep fixed

@jreback jreback force-pushed the tsbool branch 2 times, most recently from bcb3d20 to 4f4aff2 Compare March 22, 2017 18:41
@jreback jreback changed the title WIP: tests for NaT accessors COMPAT: NaT accessors Mar 22, 2017
@jreback jreback added this to the 0.20.0 milestone Mar 22, 2017
@jreback
Copy link
Contributor Author

jreback commented Mar 22, 2017

@jorisvandenbossche

@codecov
Copy link

codecov bot commented Mar 22, 2017

Codecov Report

Merging #15782 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15782      +/-   ##
==========================================
- Coverage   90.99%   90.98%   -0.02%     
==========================================
  Files         143      143              
  Lines       49386    49401      +15     
==========================================
+ Hits        44939    44946       +7     
- Misses       4447     4455       +8
Impacted Files Coverage Δ
pandas/tseries/period.py 92.73% <100%> (+0.05%) ⬆️
pandas/tseries/common.py 88.09% <100%> (ø) ⬆️
pandas/tseries/tdi.py 90.33% <100%> (+0.09%) ⬆️
pandas/tseries/index.py 95.42% <100%> (+0.02%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.56% <0%> (-0.1%) ⬇️
pandas/core/common.py 91.3% <0%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80280ec...6bc9bc0. Read the comment docs.

@jreback
Copy link
Contributor Author

jreback commented Mar 25, 2017

any comments?

TST: add pandas/tests/scalar/test_nat

TST: revise testing of tseries accessors

closes pandas-dev#15781
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jorisvandenbossche jorisvandenbossche merged commit 71f621f into pandas-dev:master Mar 27, 2017
mattip pushed a commit to mattip/pandas that referenced this pull request Apr 3, 2017
TST: add pandas/tests/scalar/test_nat

TST: revise testing of tseries accessors

closes pandas-dev#15781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return value of boolean datetime fields of NaT: False or NaN ?
2 participants