-
-
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
BUG: incorrect output of first('1M') in case if first index is the last day of the month (#29623) #30138
Changes from all commits
1542692
c4425fd
1e71cd9
7325e1a
4fa289d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. don't change unrelated things |
||
result = df.pipe(f, 2) | ||
expected = DataFrame({"A": [1, 4, 9]}) | ||
tm.assert_frame_equal(result, expected) | ||
|
@@ -922,7 +922,7 @@ def test_pipe(self): | |
|
||
def test_pipe_tuple(self): | ||
df = DataFrame({"A": [1, 2, 3]}) | ||
f = lambda x, y: y | ||
def f(x, y): return y | ||
result = df.pipe((f, "y"), 0) | ||
tm.assert_frame_equal(result, df) | ||
|
||
|
@@ -931,7 +931,7 @@ def test_pipe_tuple(self): | |
|
||
def test_pipe_tuple_error(self): | ||
df = DataFrame({"A": [1, 2, 3]}) | ||
f = lambda x, y: y | ||
def f(x, y): return y | ||
with pytest.raises(ValueError): | ||
df.pipe((f, "y"), x=1, y=0) | ||
|
||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. we need a full comparison using assert_series_equal |
||
assert("2010-04-30" not in res) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameterize over first/last |
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