Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas filter length of string

import pandas as pd

df = pd.read_csv('filex.csv')
df['A'] = df['A'].astype('str')
df['B'] = df['B'].astype('str')
mask = (df['A'].str.len() == 10) & (df['B'].str.len() == 10)
df = df.loc[mask]
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: string to float python 
Python :: sqlite check if table exists 
Python :: pathlib path python 
Python :: imblearn randomoversampler 
Python :: python convert bool to string 
Python :: import pil pycharm 
Python :: create or update django models 
Python :: numpy roundup to nearest 5 
Python :: correlation python 
Python :: df = df.reset_index(level=0) 
Python :: drop a row with a specific value of a column 
Python :: jaccard distance python 
Python :: python program to draw square 
Python :: date colomn to datetime 
Python :: python color text 
Python :: python recursive sum of digit 
Python :: axes color python 
Python :: pandas Unnamed: 0 
Python :: creating a virtual environment with django on windows 
Python :: python series get value 
Python :: pandas plot move legend 
Python :: wget command python 
Python :: twitter bot python 
Python :: matplotlib savefig not working 
Python :: count decimal number python 
Python :: access sqlite db python 
Python :: skip error python 
Python :: list with numbers between 2 values by 
Python :: sha512 python 
Python :: create an array of n same value python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =