我不知道怎么解释我的问题。。但我有一个系列,看起来像这样:
0 Male
1 Female
2 male
3 M
4 m
5 LGBT
6 Others
7 Make
8 Male
9 Man
10 Cis Male
Male
Female
Others
LGBT
我可以用以下方法缩小范围:
LGBT = survey['Gender'].str.contains('Trans|Neuter|queer|andro|Andro|Enby|binary|trans')
survey.loc[LGBT, 'Gender'] = 'LGBT'
Others = survey['Gender'].str.contains('N|A|p')
survey.loc[Others, 'Gender'] = 'Others'
Female = survey['Gender'].str.contains('F|Wo|f|wo')
survey.loc[Female, 'Gender'] = 'Female'
eq
survey['Gender'].eq(['Male', 'Female', 'Others', 'LGBT']).map({False: 'Male'})
ValueError: Lengths must be equal
我越来越困惑。。。。任何建议和帮助将不胜感激!