我被锁住了。我在下面收到错误,看不到为什么,索引是int64,所以??? 。我想遍历数据集,找到所有更改的行,并将它们的索引位置记入数组。然后使用数组依次转到每个位置,打印出下两行,然后获得下一个位置。
TypeError: slice indices must be integers or None or have an __index__ method
这是代码段和数据。
import pandas as pd
data = [['edward',1],['edward',0],['edward',0],['norm',1],['norm',0],['norm',0] ]
df_names = pd.DataFrame( data )
criteria = df_names[1] == 1
df_just_changes = df_names[ criteria ]
print(df_names)
print(df_just_changes .index)
print("type of df_just_changes.index {} ".format(type( df_just_changes.index ) ) )
print("type of df_just_changes.index[0] {} ".format(type( df_just_changes.index[0] ) ) )
print( df_names.values[df_just_changes.index : 2 ])
答案 0 :(得分:1)
您也许可以使用面罩和'fillna'来向前填充(填充)面罩。 像这样:
self.title = noteDate["title"]