...

/

Solution: Data Manipulation and Indexing

Solution: Data Manipulation and Indexing

See the solutions to the problems related to data manipulation in pandas.

Problem 1: Solution

Given a Series marks, create a Series from a numeric column of Series marks that has the value of high if it's equal to or above the mean and low if it's below the mean mean using np.select.

Press + to interact
import pandas as pd
import numpy as np
marks = pd.Series([13,45,20,46,0,90,12])
low_or_high = np.select([marks<marks.agg('mean'), marks>marks.agg('mean')], ['low', 'high'])
print(marks.tolist())
print (low_or_high)
...