documentation对于这篇文章标题中的论点,他说:
float_precision : string, default None
Specifies which converter the C engine should use for floating-point values. The options are None for the ordinary converter, high for the high-precision converter, and round_trip for the round-trip converter.
我想更多地了解所提到的三种算法,最好不要深入研究源代码1。
问:这些算法是否有名称,我可以通过谷歌搜索来准确了解它们的作用以及它们的不同之处?
(另外,一个附带问题:在这种情况下,“C 引擎”到底是什么?是 Pandas 特有的东西,还是 Python 范围内的东西?以上都不是?)
1 不熟悉所讨论的代码库,我预计我需要很长时间才能找到相关的源代码。但即使假设我设法找到它,我对这种算法的经验是它们的实现非常优化,而且在如此低的水平上,如果没有一些高水平的描述,至少对我来说,真的很难关注正在发生的事情。
最佳答案
您询问了实际算法 - 我能找到的最接近的是: https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/parsers.pyx#L492
这是从一个相关的答案中摘录的,感谢 MaxU ( Understanding pandas.read_csv() float parsing )
Ordinary: double_converter_nogil = xstrtod
High: double_converter_nogil = precise_xstrtod
Round-Trip: double_converter_withgil = round_trip
从这里开始,您就进入了 C 地。您还问为什么 pandas 使用 C - 关键代码路径是用 Cython 或 C 编写的。
关于python - 关于 pandas.read_csv 的 float_precision 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44697714/