-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
[#7292] BUG: asfreq / pct_change strange behavior #19410
Changes from 7 commits
e7f4f4e
d0baf8f
63701a3
8cfb77a
e594e04
dc9d64e
22e0c34
a1d804f
106bdf4
b6377df
b08d4c8
27aee76
75b8942
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 |
---|---|---|
|
@@ -108,7 +108,9 @@ def test_pct_change(self): | |
|
||
rs = self.tsframe.pct_change(freq='5D') | ||
filled = self.tsframe.fillna(method='pad') | ||
assert_frame_equal(rs, filled / filled.shift(freq='5D') - 1) | ||
assert_frame_equal(rs, | ||
(filled / filled.shift(freq='5D') - 1) | ||
.reindex_like(filled)) | ||
|
||
def test_pct_change_shift_over_nas(self): | ||
s = Series([1., 1.5, np.nan, 2.5, 3.]) | ||
|
@@ -120,6 +122,11 @@ def test_pct_change_shift_over_nas(self): | |
edf = DataFrame({'a': expected, 'b': expected}) | ||
assert_frame_equal(chg, edf) | ||
|
||
def test_pct_change_periods_freq(self): | ||
rs_periods = self.tsframe.pct_change(5) | ||
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. add the issue number as a comment. Can you add a few more test cases here (via parametrization if possible). include an empty frame |
||
rs_freq = self.tsframe.pct_change(periods=1, freq='5B') | ||
assert_frame_equal(rs_freq, rs_periods) | ||
|
||
def test_frame_ctor_datetime64_column(self): | ||
rng = date_range('1/1/2000 00:00:00', '1/1/2000 1:59:50', freq='10s') | ||
dates = np.asarray(rng) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,7 +344,9 @@ def test_pct_change(self): | |
|
||
rs = self.ts.pct_change(freq='5D') | ||
filled = self.ts.fillna(method='pad') | ||
assert_series_equal(rs, filled / filled.shift(freq='5D') - 1) | ||
assert_series_equal(rs, | ||
(filled / filled.shift(freq='5D') - 1) | ||
.reindex_like(filled)) | ||
|
||
def test_pct_change_shift_over_nas(self): | ||
s = Series([1., 1.5, np.nan, 2.5, 3.]) | ||
|
@@ -353,6 +355,11 @@ def test_pct_change_shift_over_nas(self): | |
expected = Series([np.nan, 0.5, np.nan, 2.5 / 1.5 - 1, .2]) | ||
assert_series_equal(chg, expected) | ||
|
||
def test_pct_change_periods_freq(self): | ||
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. same comments as above 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. added additional test cases and test when frame is empty. |
||
rs_periods = self.ts.pct_change(5) | ||
rs_freq = self.ts.pct_change(periods=1, freq='5B') | ||
assert_series_equal(rs_freq, rs_periods) | ||
|
||
def test_autocorr(self): | ||
# Just run the function | ||
corr1 = self.ts.autocorr() | ||
|
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.
Change "produces different sizes frames/series" to "returned different length outputs"
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.
corrected.