Learn how to use the where() function in Pandas to conditionally replace values in a DataFrame.
whereUse the where() function to replace all Purchase Amount (USD) values below $50 with NaN.
Display the rows of the modified DataFrame.
Python Code:
#Step: 1: To see the full number of rows and columns of df dataframe:
import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
df
#Step: 2 use where function to do the rest of the tasks:
import pandas as pd
import numpy as np
df['Purchase Amount (USD)'] = df['Purchase Amount (USD)'].where(df['Purchase Amount (USD)'] >= 50, np.nan)
df