I have a dataframe of the following type:
df = pd.DataFrame(
{
"Name": [
[
" Verbundmörtel ",
" Compound Mortar ",
" Malta per stucchi e per incollaggio ",
],
[" StoLevell In Absolute ", " StoLevell In Absolute "],
[
" Anhydrit-FlieÃ\x9festrich ",
" Anhydrite Flowing Screed ",
" Massetto a base di anidrite ",
],
],
"NAME_FILE": [
"AdhesiveCoveringPlaster_2",
"AdhesiveMortarLevellInForAEVERO_720",
"AnhydriteFlowingScreed_20",
],
}
)
I am trying to filter both columns according to certain keywords. The idea is to get a dataframe where I have the two columns, but with only the values that meet the condition.
select_materials = {
"Plaster": list(
filter(
lambda x: "Hist".casefold() in x.casefold()
or "Plaster".casefold() in x.casefold()
or "Gips".casefold() in x.casefold(),
df.FILE,
)
)
}
For the sake of convenience, I have only inserted a few lines from the entire file, but I hope my objective is clear. The result should then be a dataframe with the filters applied to both columns. If a filtered word is present in either column of the same row, then the whole row should be kept.