If I use the Pandas read_csv() function, elements of short rows are mapped to NaN by default. I would like to suppress that mapping while interpreting NA as NaN. I'm mostly interested in file truncation as a result of transmission problems, but short rows in the middle of the file should feature the same missing" value. I tried messing around with na_filter=False and keep_default_na=False, and while each seemed to map empty cells to the empty string, neither mapped the string NA to NaN.
Is there a way to have my cake (NA => NaN) and eat it too (missing values not mapped to NaN)? (I'm using Pandas 0.22.0 w/ Python 3.6.)
Example:
col1,col2,col3,col4
1,2,NA,4
4,5
12
Assume the file has been truncated, so the characters "12" are the last in the file (no EOF). With na_filter and keep_default_na at their default values of True, the resulting values are
1,2,NaN,4
4,5,NaN,NaN
12,NaN,NaN,NaN
If I set either to False, I get
1,2,NA,4
4,5,,
12,,,
I would like to find some way to get a NaN out of the third column of the first row without also mapping the missing values to NaN.