[英]Pandas Dataframe reads value of one column wrong
csv 文件: 链接到 Github
这是我的代码:
import pandas as pd
df = pd.read_csv("log_1_2018_09_07.csv", encoding="ISO-8859-1", delimiter=';')
print(df.columns.tolist())
dates = []
times = []
outputs = []
for date in df.loc[:, "Datum"]:
dates.append(date)
print("date")
print(date)
for time in df.loc[:, " Zeit"]:
times.append(time)
print("time")
print(time)
for out in df.iloc[:, 19]:
print("output")
outputs.append(out)
print(out)
它正确读取日期和时间,但第 19 列(T 列)均为 0,第 6 个值为 990,但是 pandas 将其全部读取为 0,第 9 个值读取为 1。有人知道为什么读取错误的值吗? 谢谢!!
仔细查看数据,该值实际上是1
,但由于999
占用了更多的视觉空间,因此会产生 999 是该单元格中的值的错觉。
在该列中打印df
(在任何操作之前)显示该列的实际值,没有任何意外。
import pandas as pd
url = 'https://raw.github.com/liamrisch/helper/master/log_1_2018_09_07.csv'
df = pd.read_csv(url, encoding="ISO-8859-1", delimiter=';')
df.iloc[:,[6,19]]
给出:
Teil 1-8 - Abstand Rasthaken MP1-MP2 Teil 1-8
0 26,764 0
1 26,787 0
2 26,792 0
3 26,788 0
4 26,771 0
5 999,990 0
6 26,786 0
7 26,785 0
8 26,780 1
9 26,783 0
10 26,798 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.