Pandas - pandas.DataFrame.from_csv和pandas.read_csv [英] Pandas - pandas.DataFrame.from_csv vs pandas.read_csv
问题描述
之间有什么区别:
pandas.DataFrame.from_csv
,doc链接: http://pandas.pydata.org/pandas-docs/stable/generated/ pandas.DataFrame.from_csv.html
和
熊猫。 read_csv
,doc链接: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.parsers.read_csv.html
推荐答案
没有真正的区别(两者都基于相同的底层函数),但是如注释中所述,他们有一些不同的默认值(对于
为0或无, read_csv
和<$ c>,index_col parse_dates
分别为$ c> DataFrame.from_csv 和 read_csv
支持更多参数 / code>它们只是没有通过)。
There is no real difference (both are based on the same underlying function), but as noted in the comments, they have some different default values (index_col
is 0 or None, parse_dates
is True or False for read_csv
and DataFrame.from_csv
respectively) and read_csv
supports more arguments (in from_csv
they are just not passed through).
除此之外,它是建议使用 pd.read_csv
。
DataFrame.from_csv
仅仅因为历史原因而存在,并保持向后兼容性(计划是弃用它,请参见此处),但所有新功能仅添加到 read_csv
(你可以在更长的关键字参数列表中看到)。实际上,这应该在文档中更清楚。
Apart from that, it is recommended to use pd.read_csv
.
DataFrame.from_csv
exists merely for historical reasons and to keep backwards compatibility (plans are to deprecate it, see here), but all new features are only added to read_csv
(as you can see in the much longer list of keyword arguments). Actually, this should be made more clear in the docs.
这篇关于Pandas - pandas.DataFrame.from_csv和pandas.read_csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!