我必须关注df:
Col1 Col2
test Something
test2 Something
test3 Something
test Something
test2 Something
test5 Something
我想得到
Col1 Col2 Occur
test Something 2
test2 Something 2
test3 Something 1
test Something 2
test2 Something 2
test5 Something 1
我试过使用:
df["Occur"] = df["Col1"].value_counts()
但这没有帮助。我有一个充满“NaN”的 Occur 列