Skip to content

BUG: incorrect output of first('1M') in case if first index is the last day of the month (#29623) #30138

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
wants to merge 5 commits into from

Conversation

Franklinluo17
Copy link

@Franklinluo17 Franklinluo17 commented Dec 8, 2019

@pep8speaks
Copy link

pep8speaks commented Dec 8, 2019

Hello @Franklinluo17! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 8553:1: W293 blank line contains whitespace

Line 915:9: E704 multiple statements on one line (def)
Line 925:9: E704 multiple statements on one line (def)
Line 934:9: E704 multiple statements on one line (def)

Comment last updated at 2019-12-08 03:45:40 UTC

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.

you have some extraneous files in here

@@ -912,7 +912,7 @@ def test_equals(self):

def test_pipe(self):
df = DataFrame({"A": [1, 2, 3]})
f = lambda x, y: x ** y
def f(x, y): return x ** y
Copy link
Contributor

Choose a reason for hiding this comment

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

don't change unrelated things

@@ -970,3 +970,10 @@ def test_deprecated_get_dtype_counts(self):
df = DataFrame([1])
with tm.assert_produces_warning(FutureWarning):
df.get_dtype_counts()

# test case where offset and index[0] overlap
Copy link
Contributor

Choose a reason for hiding this comment

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

move this near other tests for first: look in pandas/tests/frame/test_timeseries and series....

def test_first_index_series_last_day_of_month(self):
series = pd.Series(1, index=pd.bdate_range('2010-03-31', periods=100))
res = series.first('1M')
assert("2010-03-31" in res)
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a full comparison using assert_series_equal

series = pd.Series(1, index=pd.bdate_range('2010-03-31', periods=100))
res = series.first('1M')
assert("2010-03-31" in res)
assert("2010-04-30" not in res)
Copy link
Contributor

Choose a reason for hiding this comment

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

parameterize over first/last

@@ -8550,6 +8550,11 @@ def first(self, offset):
return self

offset = to_offset(offset)

# Check if offset and index[0] overlap
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like you simply want to set end = index[0], so do that

@jreback jreback added the Frequency DateOffsets label Dec 8, 2019
@jreback
Copy link
Contributor

jreback commented Jan 1, 2020

closing as stale, if you want to continue, pls ping.

@jreback jreback closed this Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: incorrect output of first('1M') in case if first index is the last day of the month
3 participants