📚 The CoCalc Library - books, templates and other resources
1# 1. Use the `head()` method to get the first ten rows 2df.head() 3 4# 2. Use the `drop_duplicates()` method to find all of the distinct names 5df.names.drop_duplicates().compute() 6 7# 3. Use selections `df[...]` to find how many positive and negative amounts 8# there are 9len(df[df.amount < 0]) 10 11# 3. Use selections `df[...]` to find how many positive and negative amounts 12# there are 13len(df[df.amount > 0]) 14 15# 4. Use groupby `df.groupby(df.A).B.func()` to get the average amount per user 16# ID 17df.groupby(df.names).amount.mean().compute() 18 19# 5. Combine your answers to 3 and 4 to compute the average withdrawal 20# (negative amount) per name 21df2 = df[df.amount < 0] 22df2.groupby(df2.names).amount.mean().compute() 23 24