-
Notifications
You must be signed in to change notification settings - Fork 358
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
Implement pct_change() for Series #1071
Conversation
i'm going to integrated the logic with |
Codecov Report
@@ Coverage Diff @@
## master #1071 +/- ##
==========================================
+ Coverage 95.2% 95.21% +<.01%
==========================================
Files 34 34
Lines 6863 6893 +30
==========================================
+ Hits 6534 6563 +29
- Misses 329 330 +1
Continue to review full report at Codecov.
|
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.
On second thought, we might just need:
- sdf = self._internal._sdf
- window = Window.orderBy(F.monotonically_increasing_id()).rowsBetween(-periods, -periods)
+ scol = self._internal.scol
- for column_name in self._internal.data_columns:
- prev_row = F.lag(scol_for(sdf, column_name), periods).over(window)
- sdf = sdf.withColumn(column_name, (scol_for(sdf, column_name) - prev_row) / prev_row)
-
- internal = self._internal.copy(
- sdf=sdf,
- scol=scol_for(sdf, self._internal.data_columns[0]))
+ window = Window.orderBy(F.monotonically_increasing_id()).rowsBetween(-periods, -periods)
+ prev_row = F.lag(scol, periods).over(window)
- return _col(DataFrame(internal))
+ return self._with_new_scol((scol - prev_row) / prev_row)
self.assert_eq(repr(kser.pct_change(periods=-100000000)), | ||
repr(pser.pct_change(periods=-100000000))) | ||
self.assert_eq(repr(kser.pct_change(periods=100000000)), | ||
repr(pser.pct_change(periods=100000000))) |
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.
Why are these using repr()
?
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.
@ueshin It looks really cool. thanks for spending your time for this. 👍 |
Softagram Impact Report for pull/1071 (head commit: 3e82a04)
|
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.pct_change.html#pandas.Series.pct_change