检索 pandas 中read

编程入门 行业动态 更新时间:2024-10-10 02:15:40
本文介绍了检索 pandas 中read_csv推断的定界符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用自动分隔符检测配置读取csv文件时( pd.read_csv(file_path,sep = None)),pandas会尝试推断定界符(或分隔符) )。

When using the configuration for automatic separator detection to read csv files (pd.read_csv(file_path, sep=None)), pandas tries to infer the delimiter (or separator).

是否可以检索此推断的结果(最终用于 sep 的值)?

Is there a way to retrieve the result of this inference (the value that was finally used for sep)?

编辑

我正在寻找一种使用pandas对象的方法由 read_csv 返回。我使用的是0.20.2版的熊猫。

I am looking specifically for a method that uses the pandas object that is returned by read_csv. I use version 0.20.2 of pandas.

推荐答案

我认为您无需导入就可以做到这一点。 csv :

reader = pd.read_csv(file_path, sep = None, iterator = True) inferred_sep = reader._engine.data.dialect.delimiter

编辑:

忘记了 iterator = True 参数。

更多推荐

检索 pandas 中read

本文发布于:2023-11-13 02:34:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:pandas   read

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!