Reputation: 674
I am using pandas==0.25.0 django-pandas==0.6.1
And I am using value_counts() to group for unique valor in two columns:
charges_mean_provinces = whatever.objects.filter(whatever = whatever).values('origin_province','destination_province')
df_charges_mean = pd.DataFrame(charges_mean_provinces)
df_charges_mean = df_charges_mean.value_counts().to_frame('cantidad').reset_index()
In local (development) it work correctly. But in production (I use Heroku), it return this error.
'DataFrame' object has no attribute 'value_counts'
Is there other way to group unique valor from two columns without use value_counts? Considering that I can not change my Pandas version in Heroku.
Anyway, value_counts is in pandas 0.25 documentation, so, I do not understand the error.
Upvotes: 0
Views: 4952
Reputation: 145
What version of Pandas are you using? Initially, value_counts is a method for series, rather than dataframes. You can call value_counts on a specific column, but not the frame itself.
After 1.10, that was updated and now value_counts is also a dataframe method. I recall seeing posts previously on here regarding this error before pandas was updated.
Upvotes: 2