我有一个多列的数据帧。我需要在第2列中将第4个值标记为第8个值,表示这些连续行的值等于0.1
ID Column2 Column3
1 2.6 9
2 1.9 7
3 4.7 5
4 0.1 8
5 0.1 6
6 0.1 2
7 0.1 8
8 0.1 7
9 3.0 4
10 1.2 9
11 2.8 7
12 3.1 9
13 1.0 3
14 2.4 4
15 3.2 5
n nth value nth value
我使用了下面的代码,它给了我TypeError。有人能帮忙吗?你知道吗
代码:
import pandas as pd
df = pd.read_csv('file.csv')
for row, index in df_May.iterrows():
if row['Column2'] == row['Column2'].shift(1) | row['Column2'] == 0.1:
print index,row
TypeError: 'int' object has no attribute '__getitem__'
您需要:
输出:
相关问题 更多 >
编程相关推荐