kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Get all kandi verified functions for this library.
Geppetto is an integrated toolset for developing Puppet modules and manifests.
Pandas groupby throwing KeyErrorAsked 2020-Nov-19 at 23:24
Pandas throws a KeyError for this code even though all columns exist in the dataframe and I have already checked for spaces in the name:
violations_zipcode = final_df.groupby([final_df['FACILITY ZIP', 'FACILITY NAME']])['VIOLATION DESCRIPTION'].count().reset_index(name='No. Violations').sort_values(by='No. Violations', ascending=False)
Here's what the dataframe looks like:
VIOLATION DESCRIPTION FACILITY ZIP FACILITY NAME 0 Poor hygiene 90210 Starbucks 1 Lack of seating 70024 Domino's 2 Insufficient ventilation 34567 Geppetto Pizza 3 Rodents 00345 Taco Bell 4 ..... ..... .....
What can it be?
ANSWERAnswered 2020-Nov-19 at 23:24
Your group by syntax is incorrect. It should be
final_df.groupby(['FACILITY ZIP', 'FACILITY NAME'])['VIOLATION DESCRIPTION'].count()...
Check groupby syntax:
No vulnerabilities reported
Explore Related Topics