-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Hello @Franklinluo17! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-12-08 03:45:40 UTC |
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 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 |
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.
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 |
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 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) |
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.
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) |
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.
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 |
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.
looks like you simply want to set end = index[0], so do that
closing as stale, if you want to continue, pls ping. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff