In [1]:
import numpy as np
import pandas as pd
from pandas import Series,DataFrame

In [2]:
ser1 = Series([1,2,3,4,1,2,3,4])

ser1


Out[2]:
0    1
1    2
2    3
3    4
4    1
5    2
6    3
7    4
dtype: int64

In [3]:
ser1.replace(1,np.nan)


Out[3]:
0    NaN
1    2.0
2    3.0
3    4.0
4    NaN
5    2.0
6    3.0
7    4.0
dtype: float64

In [4]:
ser1.replace([1,4],[100,400])


Out[4]:
0    100
1      2
2      3
3    400
4    100
5      2
6      3
7    400
dtype: int64

In [5]:
ser1.replace([2,3],10)


Out[5]:
0     1
1    10
2    10
3     4
4     1
5    10
6    10
7     4
dtype: int64

In [7]:
ser1.replace({4:np.nan})


Out[7]:
0    1.0
1    2.0
2    3.0
3    NaN
4    1.0
5    2.0
6    3.0
7    NaN
dtype: float64

In [ ]:


In [ ]: