我想删除for循环中dataframe中的重复行

2024-04-24 03:10:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我想通过比较几列来从dataframe生成图形,但是当它比较行时,许多图形是用相同的数据绘制的。我需要避免这种情况

我尝试使用df.drop删除多个数据,但它显示了错误

"ValueError: Need to specify at least one of 'labels', 'index' or 'columns'"

for evt in range(len(df3)): 
    if count < len(df3):

        count = count+1
        machine_name = df3.iloc[i,j]
        machine_number_filtered = df3.iloc[i,j]
        parameter_name = df3.iloc[i,k]
        axis_name = df3.iloc[i,l]
        i = i+1
        n = df3[df3['Machine'].str.contains(machine_name) & df3['Parameter'].str.contains(parameter_name) & df3['Axis'].str.contains(axis_name)] 

        n.plot(x='Date', y=['Values', 'Critical Limit','Warning Limit' ], figsize=(25,15), grid=2, linewidth = 7, marker = 'o', markersize = '10')

但它每次打印时都会重复一组与类似行相同的图形


Tags: 数据name图形dataframelenparametercountmachine