在使用pandas导入CSV文件时,如何保留加号?
我有一个CSV文件,需要导入我的项目。 CSV文件类似于以下内容:
-Inf | 2.1 | 下部颜色 |
---|---|---|
# | 00AEEF | 2.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:
lower | upper | color |
---|---|---|
-inf | 2.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论