Python uses PyJanitor's fill_ Missing, fillna, and replace functions for data filling

Environmental construction and preparation work: 1. Install Python: Go to the Python official website to download and install the latest version of Python. 2. Install PyJanitor: Use the following command to install the PyJanitor library. shell pip install pyjanitor Dependent class libraries: -Pandas: A commonly used Python library for data processing and analysis. Data sample: Suppose we have a dataset containing missing values, which includes the following columns: 'col1, col2, col3'. Complete Python code: python import pandas as pd import janitor #Create sample dataset data = { 'col1': [1, 2, None, 4, None], 'col2': [None, 6, 7, None, 9], 'col3': [None, 11, None, None, 14] } df = pd.DataFrame(data) #Using the fillna function to fill in missing values df_filled = df.fillna(0) Print ("Fill in missing values using the fillna function:") print(df_filled) #Using the replace function to replace a specific value df_replaced = df.replace(4, 10) print(" Using the replace function to replace a specific value: print(df_replaced) #Use fill_ Missing function fills in missing values df_filled_missing = df.fill_missing({"col1": 5, "col2": 8, "col3": 12}) print(" Use fill_ Missing function fills in missing values: print(df_filled_missing) Output results: Fill in missing values using the fillna function: col1 col2 col3 0 1.0 0.0 0.0 1 2.0 6.0 11.0 2 0.0 7.0 0.0 3 4.0 0.0 0.0 4 0.0 9.0 14.0 Use the replace function to replace specific values: col1 col2 col3 0 1.0 NaN NaN 1 2.0 6.0 11.0 2 NaN 7.0 NaN 3 10.0 NaN NaN 4 NaN 9.0 14.0 Use fill_ Missing function fills in missing values: col1 col2 col3 0 1.0 8.0 12.0 1 2.0 6.0 11.0 2 5.0 7.0 12.0 3 4.0 8.0 12.0 4 5.0 9.0 14.0 Summary: PyJanitor is an extension library based on the Pandas library, which provides some convenient functions to process data. In this example, we used the fill of the PyJanitor library_ Missing, fillna, and replace functions are used for data filling. By using these functions, we can easily handle missing values and replace specific values, thereby preparing the data for further analysis and processing.