我第一次嘗試使用熊貓。我有一個有兩列的數據框:user_id
和string
。每個user_id可能有多個字符串,因此多次出現在數據幀中。我想從這個派生另一個數據框;其中只列出那些至少有2個或更多strings
與之相關的user_ids
。根據列value_counts(pandas)過濾數據幀
我試過df[df['user_id'].value_counts()> 1]
,我認爲這是做這件事的標準方法,但它會產生IndexingError: Unalignable boolean Series key provided
。有人能清除我的概念並提供正確的選擇嗎?
相關和可能的欺騙:https://stackoverflow.com/questions/30485151/python-pandas-exclude-rows-below-a-certain-frequency-count – EdChum