I have a dataset that looks like this (no more than 5 columns, but may be smaller)
1,2,3 1,2,3,4 1,2,3,4,5 1,2 1,2,3,4 ....
I am trying to use pandas read_table to read this in a five-column data frame. I would like to read it without additional massage.
If i try
import pandas as pd my_cols=['A','B','C','D','E'] my_df=pd.read_table(path,sep=',',header=None,names=my_cols)
I get an error - "column names have 5 fields, data have 3 fields."
Is there a way to make pandas populate NaN for missing columns when reading data?
python pandas
Jackie Shephard Mar 06 '13 at 8:52 2013-03-06 08:52
source share