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 63 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 True
s 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
- 822,522
- 95
- 1,334
- 1,252
-
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