Solution: Data Manipulation and Indexing
See the solutions to the problems related to data manipulation in pandas.
We'll cover the following...
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.
Python 3.10.4
import pandas as pdimport numpy as npmarks = 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)
...
Ask