更新时间:2023-11-14 23:26:10
当你做 len(df['column name'])
你只是得到一个数字,即行数DataFrame(即列本身的长度).如果要将 len
应用于列中的每个元素,请使用 df['column name'].map(len)
.所以试试
When you do len(df['column name'])
you are just getting one number, namely the number of rows in the DataFrame (i.e., the length of the column itself). If you want to apply len
to each element in the column, use df['column name'].map(len)
. So try
df[df['column name'].map(len) < 2]