Error while using dask to read in csv files

Viewed 483

I am learning how to use dask.dataframe module to read in multiple csv files and when trying to read those, the error: ValueError: cannot convert float NaN to integer is thrown.

My code is as follows:

import pandas as pd
import numpy as np
import dask.dataframe as dd


for year in range(2000, 2005):
    idx = pd.date_range(str(year), str(year + 1), freq='d', closed='left')
    pd.DataFrame({'A': np.random.randn(len(idx)), 
                  'B': np.random.randint(len(idx))},
                 index=idx).to_csv('{0}.csv'.format(year), index_label='date')


df = dd.read_csv('*.csv').set_index('date')
df.head()

Each year therefore looks something like this:

date              A           B
01/01/2000  1.13334261       135
02/01/2000  -1.071303513     135
03/01/2000  0.654942826      135
04/01/2000  0.452817638      135
05/01/2000  -2.400335129     135
06/01/2000  1.47236587       135
0 Answers
Related