0

How to itterate each string of column and print another columns corresponding to matching words using python ?

I have a two string columns like : Column 1 : it is my name Column 2 : Sachin. Column1 : my name is Column 2 : sachin So when i itterate through column 1 and search for "name" it should print column 2 string for every word matching to name in column 1. How to do this using python? Can anyone please help me in this? Thank you

15th Feb 2022, 7:00 AM
Sachin Kumar Gupta
Sachin Kumar Gupta - avatar
2 RĂ©ponses
0
Just throw the data into local sqlite db and use "SELECT 'Column 2' FROM 'table' WHERE 'Column 1' LIKE '%name%' It's faster than pandas. https://www.thedataincubator.com/blog/2018/05/23/sqlite-vs-pandas-performance-benchmarks/
19th Feb 2022, 11:24 AM
Robert BƂaszczyk
Robert BƂaszczyk - avatar
0
However if You must use pandas for the task, try newdata = data.loc[data['Column 1']=='Sachin', 'Column 2'] this will create ne dataframe. If You need to update the base dataframe, do not assign the line to a new variable, just add "inplace=True"
19th Feb 2022, 11:47 AM
Robert BƂaszczyk
Robert BƂaszczyk - avatar