Question: I want to change values in a large amount of rows into something else.

I open my data from a csv using pandas as follows:

```
import pandas as pd
import numpy as np
import os

df = pd.read_csv('data.csv', encoding = "ISO-8859-") 

```

I then slice my DF changing column names:

```
df1 = df['col 1', 'col 2', 'col 3' 'col 4', 'col 5']

```

Remove useless column names:

```
df2 = df1.columns.str.strip('col') 
output:
1, 2, 3, 4, 5
a  b  a  b  c
a  c  a  a  c
b  a  c  a  b

```

Replace values so I can report from the data easier and replace useless answers. 

```
df1 = df1.replace('c', None)
df1 = df1.replace('a', 's')
df1 = df1.replace('b', 'n')

```

Now my issues are, when I strip the columns my dataframes loses all of its values, and when I try to re-concat the new df into the previous one it didn't work. 

I'm not sure how to use the df.replace on multiple values, also when I run it in different strings and try to append/merge it into the current DF it doesn't really work.

The output I'm after is:

```
   output:
    1, 2, 3, 4, 5
    s  n  s  n  NaN
    n  NaN  s  s  NaN
    n  s  NaN  s  n

```

Answer: 
You can pass your conditions to dict 

```
df.replace({'c': None,'a':'s','b':'n'})
Out[164]: 
   1     2     3  4     5
0  s     n     s  n  None
1  s  None     s  s  None
2  n     s  None  s     n

```
One way is to use a dictionary combined with [`pd.DataFrame.applymap`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.applymap.html), which applies a function elementwise.

```
d = {'c': None, 'a': 's', 'b': 'n'}

res = df.applymap(d.get)

#    1     2     3  4     5
# 0  s     n     s  n  None
# 1  s  None     s  s  None
# 2  n     s  None  s     n

```

**Explanation**

* `df.applymap` works well because *all* your values are being replaced, so `d.get` can be applied on each element without worrying about keys not being found.
* It is likely to be more efficient than `df.replace`, which replaces
each item in the dictionary sequentially.