I have a .csv
file with strings in the top row and first column, with the rest of the data as floating point numbers. I want to read it into a dataframe with the first row and column as column names and index respectively, and all the floating values as float64
.
If I use df = pd.read_csv(filename,index_col=0)
all the numeric values are left as strings.
If I use df = pd.read_csv(filename, index_col=0, dtype=np.float64)
I get an exception: ValueError: could not convert string to float
as it attempts to parse the first column as float
.
There are a large number of columns, and i do not have the column names, so I don't want to identify each column for parsing as float
; I want to parse every column except the first one.
df.convert_objects(convert_numeric=True)
You can convert the values after you have the dataFrame,