简体   繁体   English

如何删除Python Pandas中某些列值中没有一定数量的数字的观察?

[英]How to delete observation where in some column values do not have certain number of numbers in Python Pandas?

I have DataFrame with column: "col1" which has evidence number of clients.我有 DataFrame 列:“col1”,其中包含客户的证据数量。 This evidence number must have 11 numbers like for example: 56745334512.此证据编号必须有 11 个数字,例如:56745334512。

My question: How can I delete rows from my DataFrame where in "col1" values do not have 11 elements?我的问题:如何从我的 DataFrame 中删除“col1”值中没有 11 个元素的行?

假设您的 DataFrame 被称为df ,请尝试:

df = df[df["Col1"].apply(lambda x: len(str(x))) == 11]

暂无
暂无

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

相关问题 如何在某些实例没有分隔符的列上使用分隔符,python - How to use delimiter on column where some instances do not have the delimiter, python 如何在Pandas中创建数据透视表,其中一列是某些值的平均值,另一列是其他值的总和? - How do I create a pivot table in Pandas where one column is the mean of some values, and the other column is the sum of others? 如何将值添加到 pandas dataframe 中的列中的某个索引(python) - how to add values to certain index in column in pandas dataframe (python) 如何从 Pandas Python 中 DataFrame 中的列中的字符串中提取一些值? - How to extract some values from string in column in DataFrame in Pandas Python? 使用第二列中的值从 Pandas 列中删除特定数量的字母,Python - delete specific number of letters from pandas column using values from second column, Python 如何在python熊猫中标记循环数的值 - How do I label values for cycle numbers in python pandas 该脚本需要删除未使用的卷,除非它们具有某些特定值 - The script needs to delete the unused volumes unless they have some certain values 在某些数字之间建立索引的行总数-Pandas Python - Sum Rows Where Indexes Between Certain Numbers - Pandas Python 在 Pandas 中,如何快速将数字列转换为离散值? - In Pandas, how do I convert a number column to discrete values quickly? 如何添加一个包含从 0 到 X 的多个数字序列的 Pandas 列,其中 X 取决于另一列中连续数字的数量 - How to add a pandas column with several sequence of numbers from 0 to X where X depends on the number of continuous numbers in the other column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM