使用 usecols 将 CSV 文件读入 Dask DataFrames
我正在 dask 中阅读 CSV 文件,但在阅读时,我想像我们在 panads 中使用的那样“usecols”。
我目前用于 DASK 的内容,
df = dd.read_csv('myfiles.csv') #in dask
我想像我们在 pandas 中一样使用,
df = pd.read_csv('myfiles.csv',usecols=["date", "loc", "x"])
I am reading CSV file in dask but while reading, I want to "usecols" as we use in panads.
What I am currently using for DASK,
df = dd.read_csv('myfiles.csv') #in dask
I want to use like this as we can do in pandas,
df = pd.read_csv('myfiles.csv',usecols=["date", "loc", "x"])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过吗:
这是 pandas.read_csv
names 类似数组,可选
要使用的列名称列表。如果文件包含标题行,则应显式传递
header=0
来覆盖列名称。此列表中不允许有重复项。您可以使用额外的关键字参数转发到
pandas.read_csv()
。dask.dataframe.read_csv 所以甚至
可以用于你。
Have you tried:
Here is a definition from pandas.read_csv
names array-like, optional
List of column names to use. If the file contains a header row, then you should explicitly pass
header=0
to override the column names. Duplicates in this list are not allowed.You can use Extra keyword arguments to forward to
pandas.read_csv()
.dask.dataframe.read_csv so even
will work for you.