Skip to content

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

Closed

Conversation

sahildua2305
Copy link
Contributor

@sahildua2305 sahildua2305 commented Oct 3, 2016

Copy link
Contributor

@jreback jreback left a 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')
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Please check.

@codecov-io
Copy link

codecov-io commented Oct 3, 2016

Current coverage is 85.26% (diff: 100%)

Merging #14340 into master will increase coverage by <.01%

@@             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          

Powered by Codecov. Last update 96b364a...35abfd0

@sahildua2305 sahildua2305 force-pushed the frequency-empty-series-fix branch 3 times, most recently from 0920ccc to 034474a Compare October 4, 2016 22:12
Tarrasch and others added 2 commits October 6, 2016 11:25
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
@jreback jreback changed the title Frequency empty series fix BUG: Frequency not set on empty series Oct 6, 2016
@@ -79,3 +79,5 @@ Performance Improvements

Bug Fixes
~~~~~~~~~

- Bug in ``asfreq``, where frequency wasn't set for empty series (:issue:`14320`)
Copy link
Contributor

Choose a reason for hiding this comment

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

series -> Series

Copy link
Contributor

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')
Copy link
Contributor

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')
Copy link
Contributor

Choose a reason for hiding this comment

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

empty =

Copy link
Contributor

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"]),
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor Author

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?

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Datetime Datetime data dtype and removed Indexing Related to indexing on series/frames, not to indexes themselves labels Oct 6, 2016
jorisvandenbossche and others added 13 commits October 6, 2016 17:57
…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
@sahildua2305 sahildua2305 force-pushed the frequency-empty-series-fix branch from 35abfd0 to c40a213 Compare October 13, 2016 16:21
@jreback
Copy link
Contributor

jreback commented Oct 19, 2016

@sahildua2305 you need to rebase on master

git rebase -i origin/master

@sahildua2305
Copy link
Contributor Author

Oops! Last time I rebased this branch it was fine. I will do that again.

@jreback
Copy link
Contributor

jreback commented Oct 19, 2016

if that doesn't work, then close and open a new PR. We had shifted the url of the repo.

@sahildua2305
Copy link
Contributor Author

Sure!

@sahildua2305 sahildua2305 deleted the frequency-empty-series-fix branch October 19, 2016 23:27
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Oct 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Frequency not set for empty Series
10 participants