ggpy: ggplot doesn't work with latest pandas dataframe
Here’s the error I get. This is due to dataframe api change.
'DataFrame' object has no attribute 'sort'
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 9
- Comments: 24
Here’s the error I get. This is due to dataframe api change.
'DataFrame' object has no attribute 'sort'
It is October already and
pandasadvanced to version0.20.3. This problem should be fixed as it rendersggplotunusable for a lot of use-cases.This is actually already fixed in the code (https://github.com/yhat/ggpy/commit/9d00182343eccca6486beabd256e8c89fb0c59e8). If you
it should work.
@chethanjjj Though it’s an awesome plotting library, for me it’s the Grammar in R’s ggplot2 that matters, so Seaborn won’t suffice. If you’re in my camp, try Plotnine, which I found from this tutorial from @pteehan.
On line 602 of ggplot/ggplot.py, I changed the line from
fill_levels = self.data[[fillcol_raw, fillcol]].sort(fillcol_raw)[fillcol].unique()to
fill_levels = self.data[[fillcol_raw, fillcol]].sort_values(by=fillcol_raw)[fillcol].unique()and it worked for my use case. Hope that helps…
In case it helps anyone, I received a similar error when trying to import ggplot:
Here are my pkg vers:
I first tried this, but it did not resolve my error:
Because “There hasn’t been an update to master since Nov 2016. At this point I think it’s safe to say this package isn’t supported anymore” - @asbhat , I switched over to plotnine, which (as far as I can tell) has the same API as ggplot. Life is good again.
Any news regarding this issue?
If people are interested in playing whack-a-mole through the python, in addition to [jmcarpenter2 's] (https://github.com/yhat/ggpy/issues/612#issuecomment-344025852) comment, there is another instance of
sortinggplot/stats/stat_smooth.pyChange
smoothed_data = smoothed_data.sort('x')to
smoothed_data = smoothed_data.sort_values('x')