I have a csv-file with a column with strings and I want to read it with pandas. In this file the string null
occurs as an actual value and should not be regarded as a missing value.
Example:
import pandas as pd
from io import StringIO
data = u'strings,numbers
foo,1
bar,2
null,3'
print(pd.read_csv(StringIO(data)))
This gives the following output:
strings numbers
0 foo 1
1 bar 2
2 NaN 3
What can I do to get the value null
as it is (and not as NaN) into the DataFrame? The file can be assumed to not contain any actually missing values.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…