data science student I need to replace a specific value in a particular column with NaN. Here is what I tried but it didn't work.

# Names of the columns we're searching for missing values 
columns = ['median', 'p25th', 'p75th']

# Take a look at the dtypes
print(recent_grads.columns.dtype)

# Find how missing values are represented
print(recent_grads["median"].unique())
print(recent_grads["p25th"].unique())
print(recent_grads["p75th"].unique())

# Replace missing values with NaN
for column in columns:
    recent_grads.loc[recent_grads.columns == 'UN', column] = np.nan
If I understood your question correctly, you can do something like:

import numpy as np

columns = ['median', 'p25th', 'p75th']
df[columns] = df[columns].replace(r'UN', np.nan, regex=True)