(20200410已解决)ValueError: cannot set a frame with no defined index and a scalar

  • 问题描述

    df_c.loc[:,'new_c'] = value出现如题错误。

  • 解决方案

    原因是被赋值的df_c是空的。

    将原数据集中先设置一列value,在df_c这里直接取df的列不直接赋值。

    df.loc[:,'new_c1'] = value
    df_c = df.copy()
    df_c.loc[:,'new_c'] = df['new_c1']
    
  • References

  1. Cannot set a frame with no defined index and a value that cannot be converted to a Series
发布了871 篇原创文章 · 获赞 1322 · 访问量 97万+

猜你喜欢

转载自blog.csdn.net/The_Time_Runner/article/details/105446588