-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Frequency not set on empty series #14340
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
BUG: Frequency not set on empty series #14340
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a release note in 0.20
@@ -323,6 +323,10 @@ def test_asfreq_datetimeindex(self): | |||
ts = df['A'].asfreq('B') | |||
tm.assertIsInstance(ts.index, DatetimeIndex) | |||
|
|||
def test_asfreq_datetimeindex_empty_series(self): | |||
s = Series(index=pd.DatetimeIndex([]), data=[]).asfreq('H') | |||
self.assertEqual(s.index.freq, 'H') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
construct an expected series and test against that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Please check.
Current coverage is 85.26% (diff: 100%)@@ master #14340 diff @@
==========================================
Files 140 140
Lines 50632 50635 +3
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43170 43173 +3
Misses 7462 7462
Partials 0 0
|
0920ccc
to
034474a
Compare
The warning is about something that have been fixed for almost 3 years. Every time a new user excited about pandas start reading the docs, they have to waste brain-cycles ignoring that big red warning bubble.
…rors on 32-bit closes pandas-dev#14345 Author: mattrijk <[email protected]> Closes pandas-dev#14347 from MattRijk/issue#14345 and squashes the following commits: 73ad3d7 [mattrijk] line 2710 formatting update for whitespace ea4f151 [mattrijk] second formatting update for whitespace 262492f [mattrijk] TST: pandas-dev#14345 fixes TestDatetimeIndexOps test_nat AssertionErors
@@ -79,3 +79,5 @@ Performance Improvements | |||
|
|||
Bug Fixes | |||
~~~~~~~~~ | |||
|
|||
- Bug in ``asfreq``, where frequency wasn't set for empty series (:issue:`14320`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
series -> Series
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to 0.19.1
@@ -323,6 +323,12 @@ def test_asfreq_datetimeindex(self): | |||
ts = df['A'].asfreq('B') | |||
tm.assertIsInstance(ts.index, DatetimeIndex) | |||
|
|||
def test_asfreq_datetimeindex_empty_series(self): | |||
empty_series = Series(index=pd.DatetimeIndex([]), data=[]).asfreq('H') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number as a comment
@@ -323,6 +323,12 @@ def test_asfreq_datetimeindex(self): | |||
ts = df['A'].asfreq('B') | |||
tm.assertIsInstance(ts.index, DatetimeIndex) | |||
|
|||
def test_asfreq_datetimeindex_empty_series(self): | |||
empty_series = Series(index=pd.DatetimeIndex([]), data=[]).asfreq('H') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need date=[]
@@ -323,6 +323,12 @@ def test_asfreq_datetimeindex(self): | |||
ts = df['A'].asfreq('B') | |||
tm.assertIsInstance(ts.index, DatetimeIndex) | |||
|
|||
def test_asfreq_datetimeindex_empty_series(self): | |||
empty_series = Series(index=pd.DatetimeIndex([]), data=[]).asfreq('H') | |||
normal_series = Series(index=pd.DatetimeIndex(["2016-09-29 11:00"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected =
empty_series = Series(index=pd.DatetimeIndex([]), data=[]).asfreq('H') | ||
normal_series = Series(index=pd.DatetimeIndex(["2016-09-29 11:00"]), | ||
data=[3]).asfreq('H') | ||
self.assertEqual(empty_series.index.freq, normal_series.index.freq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tm.assert_series_equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback But we actually want to compare the frequency of the index not the complete series. Also, if we have one empty and one non-empty series, how can we use assert_series_equal
method?
…4195 (pandas-dev#14228) Added a small warning that if `float_format` is set then floats will be quoted even if csv.QUOTE_NONNUMERIC is set
closes pandas-dev#14252 Fixes a bug where `pd.concat` didn't propagate the names of keys used to create a hierarchical index. Author: Ben Kandel <[email protected]> Closes pandas-dev#14292 from bkandel/fix_concat_key_name and squashes the following commits: cdc76f6 [Ben Kandel] take out _ensure_index 4a301f8 [Ben Kandel] put back in Index coercion d8e2c17 [Ben Kandel] remove coercion to Index before _ensure_index 44932cc [Ben Kandel] changed whatsnew entry to 0.19.1 c51df19 [Ben Kandel] _ensure_index b54b081 [Ben Kandel] simplified logic 3256119 [Ben Kandel] typo 789ecd4 [Ben Kandel] use _ensure_index 350e724 [Ben Kandel] simplified logic 9615a69 [Ben Kandel] extra tests 5c0108b [Ben Kandel] comments dd3c4cc [Ben Kandel] comments 5cd8392 [Ben Kandel] added test for names bc5f1fb [Ben Kandel] cleanup ef6db68 [Ben Kandel] BUG: Propagate key names in concat.
`MultiIndex.set_levels`, when passed in illegal level values, raises an error. When `inplace=True`, though, the illegal level values are still accepted. This commit fixes that behavior by checking that the proposed level values are legal before setting them.
…projects (pandas-dev#14406) As per [their blog post of the 27th April](https://blog.readthedocs.com/securing-subdomains/) ‘Securing subdomains’: > Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard. Test Plan: Manually visited all the links I’ve modified.
Add test to verify frequency for empty series Update test to compare empty series behaviour against normal series Add entry in whatsnew 0.20.0
35abfd0
to
c40a213
Compare
@sahildua2305 you need to rebase on master
|
Oops! Last time I rebased this branch it was fine. I will do that again. |
if that doesn't work, then close and open a new PR. We had shifted the url of the repo. |
Sure! |
git diff upstream/master | flake8 --diff