Replace a value in a Dataframe with NaN

PHOTO EMBED

Fri Dec 01 2023 03:42:21 GMT+0000 (Coordinated Universal Time)

Saved by @ktyle #python #pandas

# Assume -9999 is a missing data flag
df.replace(-9999, np.NaN)
# Alternatively, perform this when creating the dataframe:
pd.read_csv("https://www.atmos.albany.edu/products/metarCSV/world_metar_latest.csv", sep='\s+',na_values=['9999.00','-9999.0'])
content_copyCOPY

https://stackoverflow.com/questions/34794067/how-to-set-a-cell-to-nan-in-a-pandas-dataframe