Edition Reviews Ratings BookCategory Price Edition_year
165 Paperback,– Import, 5 Jul 1996 4.5 out of 5 stars 2 customer reviews Sports 270.00 1996
166 Hardcover,– 18 Aug 2009 4.5 out of 5 stars 2 customer reviews Language, Linguistics & Writing 61.00 2009
167 Paperback,– 26 Jul 2018 3.7 out of 5 stars 23 customer reviews Crime, Thriller & Mystery 184.00 2018
168 Paperback,– Import, 22 Mar 2018 4.2 out of 5 stars 50 customer reviews Romance 70.00 2018
169 Paperback,– Abridged, Import 5.0 out of 5 stars 2 customer reviews Action & Adventure 418.00 port
170 Paperback,– 10 Jan 2018 4.7 out of 5 stars 4 customer reviews Sports 395.00 2018
171 Paperback,– Apr 2011 4.0 out of 5 stars 197 customer reviews Language, Linguistics & Writing 179.00 2011
172 Paperback,– 17 Feb 2009 5.0 out of 5 stars 2 customer reviews Comics & Mangas 782.00 2009
173 Paperback,– 22 Aug 2000 3.5 out of 5 stars 4 customer reviews Language, Linguistics & Writing 475.44 2000
174 Paperback,– 5 Jan 2012 4.0 out of 5 stars 30 customer reviews Humour 403.00 2012假设在这些dataframe中,在Edition_year列下,我希望删除版本年份的值不是数值的行。也就是说,有一些值是字符串。我已经尝试过.drop()方法,但不能满足所需的输出。
这就是我试过的:
df = df.drop(df[df['Edition_year'].apply(lambda x: str(x).isalpha())].index, inplace = True)发布于 2022-03-27 13:46:12
您可以使用以下方法确定数值的Edition_year
numeric_filter = df.Edition_year.astype(str).str.isnumeric()然后使用筛选器只选择所需的行。
df = df.loc[numeric_filter]https://stackoverflow.com/questions/71499666
复制相似问题