我有一个pandas dataframe context,有两列type1和Context Interpretation。
type1有一些空值,当Context Interpretation列为空时,我希望将该值从type1列复制到该列。
到目前为止,我有这样的想法:
context.loc[context['type1']==''] = context['Context Interpretation']我还有多远?
发布于 2021-02-22 22:21:26
如何在loc中使用type1
context.loc[context['type1']=='', 'type1'] = context['Context Interpretation']发布于 2021-02-22 22:36:17
您可以使用fill of ()函数,该函数将使用您选择的值填充空值:
context["type1"].fillna(inplace=True, value=context["Context Interpretation"])https://stackoverflow.com/questions/66317475
复制相似问题