-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
feat: Added diff() function to DataFrame #414
Conversation
Should be about as near full coverage as possible
Calculate difference between rows, columns, series or another dataframe
Resolves #383 partially, there's no |
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.
Great work so far @NeonSpork ! and thanks for taking out time to contribute. I dropped some general suggestions, if you need any input from me, don't hesitate to ping me.
Another comment. I have implemented the pct_change() as well, but am struggling with testing. My expected return is for example Edit: Since it breaks testing I'm doing |
refactor: Make series array generation more succinct
Yeah, I have had that issue with float values as well. You can try to truncate/floor the value. And yes, doing pct_change in a separate PR is better. |
We can cross that bridge in another PR! 👍 I'm trying to refactor and remove some duplication, should hopefully not take too long! |
Alright! I think I've resolved the issues you pointed out @risenW ? The code has become more succinct with less duplication, and tests are passing! |
@NeonSpork Everything looks good here. One last thing before I merge, can you also add test for the browser version. Just copy over what you currently have to the browser test folder, and then use the namespace |
Sounds great! I forgot about the browser tests, oops! Was just happy to see green checks 👍 I'll sort that out in both my PRs in a short bit! |
LGTM ✅✅ Thanks for the awesome work @NeonSpork |
My pleasure man! I'm looking forward to contributing more in the future 🚀 |
@NeonSpork @risenW - this feature is exactly what I am searching for, however, I cannot find it in the docs. Could you maybe point me to the documentation? |
Hi! Glad you've found my contribution useful! When I wrote that contribution I also added pages to the docs, but for some reason they're not on the official documentation web page. Not sure why that is the case. Either way the docs pages I added are still in the docs repo, and the examples and explanations for the Maybe @risenW has some insight into why it's not on the main docs? Maybe the main index page doesn't include links to them? |
Added a diff() function to mimic the functionality of the equivalent function in pandas as best as possible.
Can calculate difference between rows and columns both forwards and backwards, in addition to difference in relation to another dataframe or series.
Added the function to the DataFrame interface.
Added unit testing with as much coverage as I could. The error that is thrown if the axis is set as something other than 0 or 1 follows the convension from a similar function, but as far as I can tell TypeScript won't let you set axis to anything besides 0 or 1, so it is untestable.
The implementation is made using the built in tensorflow functionality for pretty much everything except nudging the data to compare, and I believe this is one of the faster ways to achieve this!