简体   繁体   English

如何从数值数据中删除非数值数据?

[英]How to remove non-numeric data from numerical data?

I want to remove non-numeric data from numerical data.我想从数字数据中删除非数字数据。 My dataframe has 720000 rows and 11 columns and there is one column which has this type of data我的 dataframe 有 720000 行和 11 列,并且有一列包含此类数据

id1080784 id1080784

id0889885 id0889885

id0857912 id0857912

id3744273 id3744273

id0232939..... id0232939.....

I want to remove the 'id' word from all of these rows.我想从所有这些行中删除“id”字。 Please share your suggestions in Python only.请仅在 Python 中分享您的建议。

Thanks!谢谢!

One method is that you can use str replace.一种方法是您可以使用 str 替换。 And just replace 'id' with nothing.只需将“id”替换为空即可。

import pandas as pd
col = pd.DataFrame(['id1080784', 'id0889885', 'id0857912', 'id3744273'])
col[0] = col[0].str.replace('id','')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM