How to get the mode of a column in pandas where there are few of the same mode values pandas
- 阅读更多 关于 How to get the mode of a column in pandas where there are few of the same mode values pandas
问题 I have a data frame and i'd like to get the mode of a specific column. i'm using: freq_mode = df.mode()['my_col'][0] However I get the error: ValueError: ('The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()', 'occurred at index my_col') I'm guessing it's because I have few mode that are the same. I need any of the mode, it doesn't matter. How can I use any() to get any of the mode existed? 回答1: For me your code working nice with sample data. If