'how to find value inside pandas columns
I have a pandas column :'function' ,of jobs functions: IT,HR etc.. but I have them in few variations for each function. ('IT application','IT,Digital,Digital' etc..) I wanted to change all values that contains IT -> IT for example.
I tried:
df['function'].str.contains('IT')
df['function'].isin(['IT'])
which gives only partial results.
I wanted something like: 'IT' in df.loc[:,'function']
but a solution that would work for all the column and not for 1 index at a time. if there is a solution that doesn't need a loop that would be great.
Solution 1:[1]
This should work:
df['function'] = df.function.str.replace(r'(^.IT.$)', 'IT')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | odevney |
