I have a table with 118000118,000 rows and 80 columns, and. I needwould like to select 8 columns from the table. I am reading the file using pandas' pd.read_csvthe pandas function pd.read_csv
command as:
df = pd.read_csv(filename, header=None, sep='|',
usecols=[1,3,4,5,37,40,51,76])
I
df = pd.read_csv(filename, header=None, sep='|',
usecols=[1,3,4,5,37,40,51,76])
I would like to change the data type of each column inside of read_csvread_csv
using dtype={'5': np.float, '37': np.float, ....})dtype={'5': np.float, '37': np.float, ....}
, but this does not work.
There is a message that column 5 has mixed types. TheThe command print(df.dtypes)print(df.dtypes)
shows all columns of the type object. When I examine the column 5, I cannot see any problems. I have to change the data type for each column separately using pd.to_numeric.
My question is:
Is Is there a way of setting data types inside read_csvread_csv
and what is the problem in this case?
Many thanks!