March 2020
Beginner to intermediate
352 pages
8h 40m
English
Often, it is essential to find and replace some values inside a dataframe. This can be done with the following steps:
import numpy as npreplaceFrame = pd.DataFrame({'column 1': [200., 3000., -786., 3000., 234., 444., -786., 332., 3332. ], 'column 2': range(9)})replaceFrame.replace(to_replace =-786, value= np.nan)
The output of the preceding code is as follows:

Note that we just replaced one value with the other values. We can also replace multiple values at once.
replaceFrame = pd.DataFrame({'column 1': [200., 3000., -786., 3000., ...Read now
Unlock full access