I have multiple columns with the status of the areas, I need to get the status on status column if all the status are completed.
Asked
Active
Viewed 40 times
1 Answers
0
You can filter all columns with Area in columns names by DataFrame.filter, compare by DataFrame.eq for == and test if all Trues per rows by DataFrame.all:
df['Status'] = df.filter(like='Area').eq('Completed').all(axis=1)
Or you can seelct all columns without first 2 by DataFrame.iloc:
df['Status'] = df.iloc[:, 2:].eq('Completed').all(axis=1)
Or last 3 columns:
df['Status'] = df.iloc[:, -3:].eq('Completed').all(axis=1)
jezrael
- 729,927
- 78
- 1,141
- 1,090
-
thanks ...i need to know how can i find the extact word,even am getting the similar word – Deepweber Feb 03 '20 at 07:04
-
@Deepweber - Not easy, need [fuzzy match](https://stackoverflow.com/questions/38577332/apply-fuzzy-matching-across-a-dataframe-column-and-save-results-in-a-new-column) – jezrael Feb 03 '20 at 07:06