Category : dataframe

This code will count the number of elements in column c2 that have value greater than or equal 3 import pandas as pd df = pd.DataFrame({‘c1’: [‘A’, ‘B’,’C’,’D’,’E’], ‘c2′: [3, 1, 0,2,5]}) count=df.loc[:,’c2’] count=count[~ (count<3)] count=count.shape[0] Is there a direct way of counting these elements instead of a three line code? Source: Python..

Read more

I have the following piece of code where I’m trying to perform a group by aggregation on a pivot table and concatenate the resulting aggregation back into the pivot table dataframe. But I’m having issues joining tables of different levels. import pandas as pd data = [ ["alice", "school 1", "math", 95], ["alice", "school 1", ..

Read more