Pandas DataFrame 单元作为计数器我正在尝试创建一个熊猫数据帧“B”,同时考虑到另一个数据帧“A”的逐行读取。问题是我想填充新数据帧“B”的单元格值,计算第一个数据集“A”中发生的特定情况。我不能用全零初始化数据帧“B”,因为我不知道它将有多少行。如果我不初始化 DataFrame "B" 的单元格值,我会收到此错误KeyError: "the label ['0'] is not in the [index]"当我尝试:for i in range(len(df_A.index)): if (int(df_A.iloc[i][3])) == sec_types_crmc[3]: df_B.at["'"+str(i)+"'", 'bin_0'] = df_B.loc["'"+str(i)+"'"]['bin_0'] + 1
添加回答
举报
0/150
提交
取消