replace some values in column pandas with null code example
Example 1: how to replace nan with 0 in pandas
df['product']=df['product'].fillna(0)
df['context']=df['context'].fillna(0)
df
Example 2: replace "-" for nan in dataframe
df.replace(np.nan,0)
Example 3: fillna string
# importing pandas module
import pandas as pd
# making data frame from csv file
nba = pd.read_csv("nba.csv")
# replacing na values in college with No college
nba["College"].fillna( method ='ffill', inplace = True)