dataframe在以条件查找满足条件的行时,因为列类型为object会失败,需要更改列类型,如下:
df_gc["PCI"] = df_gc["PCI"].astype(‘int‘)
取值字典中最大的N个数值如下:
sorted_x = sorted(dic.items(), key=lambda x: x[1],reverse=True)
best_5 = sorted_x[:5]
更改dataframe中的某个单元格的值:
df_gc.loc[(df_gc.小区号 == df.iloc[m]["小区号"]), ‘PCI‘] = best
原文:https://www.cnblogs.com/huangyz-xy/p/13511559.html