代码之家  ›  专栏  ›  技术社区  ›  singularity2047

在python中实现if-then逻辑时的TypeError问题

  •  0
  • singularity2047  · 技术社区  · 6 年前

    我正在使用一个if-then逻辑,它看起来如下所示。我想在日期列没有任何空值时转换日期格式。

    mask = df['date'].isnull()
    df['a'] = df['date'].dt.strftime('%Y-%m-%d')
    df.loc[(-mask), 'date'] = df['a']
    

    它在我的windows机器和ec2的Linux环境中都能工作。但当我试着在Databricks笔记本上运行时,它显示TypeError。

    enter image description here

    enter image description here

    我需要帮助来理解错误,特别是当它在其他地方运行时没有任何错误

    0 回复  |  直到 6 年前