-2

I want to put the word "null" instead of question marks. How can I do it? (this is pandas data frame) {my code and my data frame]1

 import pandas as pd
df = pd.read_csv(r'C:\Users\ASUS\Downloads\bridges.csv' , header=None)
df.columns = ["IDENTIF", "RIVER", "LOCATION", "ERECTED","PURPOSE", "LENGTH", "LANES", "CLEAR-G","T-OR-D", "MATERIAL", "SPAN", "REL-L","TYPE"]
print(df)
hiva
  • 3
  • 6

1 Answers1

0

Try

df = df.replace('?', "Null")

Or, you probably actually want to use:

import numpy as np    
df = df.replace('?', np.nan)
Tom McLean
  • 5,583
  • 1
  • 11
  • 36
  • No worries. In the future if you dont want your question to be downvoted, you should post your code rather than a screenshot. If you paste your code then press the { } button, it will format it as code. If this has worked please press the answered tick :) – Tom McLean Apr 29 '21 at 13:19