While reading csv file df = pd.read_csv('lightcurve.csv',header=None)
and creating the dataframe, my datatypes is in objects. How can I read my csv so that I can do df.dropna
to remove all NULL values. There is also NULL values in my csv. Any suggestions would be great help.
The image of my data in csv file is : enter image description here
Based on the information provided I feel this is how your data looks like.
import numpy as np
import pandas as pd
from io import StringIO
inp = StringIO("""1,22.3,53,5.5
23,34.5,5,7.2
43,n,n,n""")
df = pd.read_csv(inp,header=None)
print(df)
df = df.replace('n',np.nan).dropna()
print(df)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.