簡體   English   中英

Python - Pandas - Dataframe 如何在使用.count時將notnull添加到列

[英]Python - Pandas - Dataframe How to add notnull to a column when using .count

我正在創建一個新列,該列將計算所有 ID,但排除幾行客戶 ID 具有特定前綴且沒有重復訂單的客戶

df['newcolumn'] = df[(df.notnull['Date']) & (df['ID'].str.contains('prefix')) & (df['Repeat order'] == 'No')].groupby(['ID'], as_index=False).count()

我得到以下錯誤

TypeError: 'method' object is not subscriptable

當我用 () 替換 [] 來解決上述錯誤時仍然沒有區別

改變

df.notnull['Date']

df['Date'].notnull()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM