Category : pandas-groupby

I need to create a dataframe filtering out the five most frequently listed countries in the Nationality column and the total amount of times they are listed. I’ve been trying to use groupby, but have been unsuccessful. The code i’ve used it df.groupby([‘Nationality’]).sum() I also need to determine what percent of those listed as participating ..

Read more

I have a dataframe: data = {‘first_column’: [‘first_value’, ‘second_value’, …], ‘second_column’: [‘yes’, ‘no’, …], ‘third_column’: [‘first_value’, ‘second_value’, …], ‘fourth_column’: [‘yes’, ‘no’, …], } I’m trying to groupby ‘first_column’, when values in ‘second_column’ and ‘fourth_column’ == ‘yes’ and I get an error: "TypeError: unsupported operand type(s) for &: ‘list’ and ‘list’ " I receive no errors ..

Read more

I read a CSV file and I created the two following lists. For each class, I wish to create a scatter plot between values2 and values3. I wanna see the correlation between values2 and values3 for each class. Is this possible? List1=vehiclesData.groupby(‘Class’)[‘values2’].apply(list) List2=vehiclesData.groupby(‘Class’)[‘values3’].apply(list) If you print List1, it will look like this: Compact Cars [2.2, ..

Read more