4
df = dd.read_csv('csv',usecols=fields,skip_blank_lines=True)
len(df.iloc[0:5])

The above code raises

AttributeError: 'DataFrame' object has no attribute 'iloc'

tried ix loc but unable select rows based on index

iacolippo
  • 4,133
  • 25
  • 37
madnavs
  • 137
  • 2
  • 8

2 Answers2

4

Dask.dataframe does not support iloc. Generally it's quite hard to do access any particular row in a csv file without first reading it all into memory.

However if you only want a few of the rows at the top then I recommend using the .head() method

>>> df.head()
MRocklin
  • 55,641
  • 23
  • 163
  • 235
3

One workaround is to create the index as a column, i.e. df_index, in your csv file and use it like so:

selection = (df[ df['df_index'].isin( list_of_indexes ) ]).compute()
scottlittle
  • 18,866
  • 8
  • 51
  • 70