I need to compare 2 columns to find cells that contain the same words and create a third column with the result. [![https://i.stack.imgur.com/EhDim.jpg%5C]]
i did that but it only compares cells in the same row and I need it to look for repeated values ββin the column .
import pandas as pd
import numpy as np
details = {
'Column1': ['site.com/auto-new/car', 2, 30, 0],
'Column2': ['site.com/auto/car', 1 , 25, 3]
}
df = pd.DataFrame(details)
df['NEW'] = np.where((df['Column1'].str.endswith('car')) & df['Column1'].str.contains('auto') & df['Column2'].str.endswith('car') & df['Column2'].str.contains('auto'), df['Column2'], np.nan)
print(df)
I should to convert dataframe to array like this?https://stackoverflow.com/questions/13187778/convert-pandas-dataframe-to-numpy-array I need This [](https://i.stack.imgur.com/oK3Zl.jpg)