在使用pandas导入CSV文件时,如何保留加号?

发布于 2025-02-11 06:36:09 字数 683 浏览 1 评论 0原文

我有一个CSV文件,需要导入我的项目。 CSV文件类似于以下内容:

-Inf2.1下部颜色
00AEEF2.1
+INF#ED1C24

lower,upper,color
-inf,2.1,#00AEEF
2.1,+inf,#ED1C24

我的代码如下:

import pandas as pd
df = pd.read_csv('rules.csv')

for i, r in df.iterrows():
    low = r['lower']
    high = r['upper']

    print(low,high)

输出是:

-inf 2.1
2.1 inf

我的问题是为什么它是inf> inf而不是<<代码>+inf 就像数据一样吗?是否有一种方法可以修改导入过程?

I have a CSV file that I need to import into my project. The CSV file is similar to this:

loweruppercolor
-inf2.1#00AEEF
2.1+inf#ED1C24

or

lower,upper,color
-inf,2.1,#00AEEF
2.1,+inf,#ED1C24

And my code is as follows:

import pandas as pd
df = pd.read_csv('rules.csv')

for i, r in df.iterrows():
    low = r['lower']
    high = r['upper']

    print(low,high)

The output was:

-inf 2.1
2.1 inf

My question is why was it inf and not +inf just like the data? And is there a way to modify the importing process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文