df is a table of lek.
Swap 0 for 5 in df, assign the result to swapped, and print swapped.
Write a function named tidy_kit that takes a kit table df and returns it after dropping later copies of duplicated rows, renaming the column g to grams, and dropping the column bin.
>>> df = pd.DataFrame({"ware": ["bolt", "nut", "bolt", "pin"], "g": [20, 14, 20, 6], "bin": [1, 2, 1, 3]})
>>> tidy_kit(df)
ware grams
0 bolt 20
1 nut 14
3 pin 6
Write a function named quiz_count that takes a table of quiz marks df and a number n. Fill missing values in the mark column with n, drop leftover missing rows, and return how many names remain.
>>> df = pd.DataFrame({"kid": ["Hiro", "Amina", "Gjon"], "mark": [62, None, 71], "room": [1, 2, None]})
>>> quiz_count(df, 0)
2
s is a Series of marks.
Cap s at a min of 50 and a max of 80, assign the result to capped, and print capped.
df is a table of quiz marks.
Drop the rows of df that have a missing value, assign the result to kept, and print kept.
Write a function named shop_report that takes a shop table df and a list of column names names, and returns a report with only those columns.
>>> shop_report(pd.DataFrame({"ware": ["mug", "pot", "tin"], "lek": [12, 35, 8], "bin": [2, 1, 3]}), ["ware", "lek"])
ware lek
0 mug 12
1 pot 35
2 tin 8
s is a Series of walk km.
Get a mask of the missing values of s, assign it to mask, and print mask.
df is a table of harvest kg.
Drop the bag column of df, assign the result to kept, and print kept.
Write a function named whole_total that takes a Series of kg s, a number low, and a number high, and returns the total of s after capping at that min and max and rounding to whole numbers.
>>> s = pd.Series([0.2, 11.6, 4.4, 7.8]) >>> whole_total(s, 1, 10) 23.0
Write a function named tidy_cafe that takes a cafe table df and returns it after dropping later copies of duplicated rows, renaming the column euro to price, and dropping the column cup.
>>> df = pd.DataFrame({"drink": ["cocoa", "mint", "cocoa"], "euro": [3, 4, 3], "cup": [1, 2, 1]})
>>> tidy_cafe(df)
drink price
0 cocoa 3
1 mint 4