Error message in Kaggle when reading in csv file

375 views Asked by At
data = pd.read_csv('/kaggle/input/covidtracking/all-states-history.csv', index_col=0, parse_dates=True)
data.shape
/opt/conda/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3063: 
DtypeWarning: Columns (2) have mixed types.
Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
(16931, 41)

Column (2) has quality rating elements with values such as A, A+, B, B+ etc

In the CSV file the data type listed above each column is "standard".

1

There are 1 answers

0
Soheila Hg On

It means your CSV file has a column that consists of several different dtypes. Just add low_memory=False to your read_csv function, and the warning message would be gone.

data = pd.read_csv('/kaggle/input/covidtracking/all-states-history.csv', low_memory=False, index_col=0, parse_dates=True)

But the problem is still there!

A better solution is to specify the column type. For example in your case, Columns (2):

data = pd.read_csv('/kaggle/input/covidtracking/all-states-history.csv', dtype={2: str}, index_col=0, parse_dates=True)