Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to drop rows if text in column if fully latin?

i have a dataframe with column sent:

sent
"error was found"
"я ищу новый error"
"загрузка завершена"
"new file is uploaded"

as you see some rows are fully latin strings, some are mixed and some are fully non-latin. i’d like to drop rows with fully latin string rows. so desired output is:

sent
"я ищу новый error"
"загрузка завершена"

how could i do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

P.S.

I consider letters like ĄŻĆ latin as well

>Solution :

You can remove lines that has no Cyrillic letters.

import pandas as pd

sent = ["error was found",
"я ищу новый error",
"загрузка завершена",
"new file is uploaded"]

df = pd.DataFrame(sent, columns=['sent'])
df = df[df['sent'].str.contains('[а-яА-Я]')] # filter dataframe

print(df)

Output

                 sent
1   я ищу новый error
2  загрузка завершена
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading