I am trying to fill the missing values in the data frame, but all of the values were replaced with None
.
Here is the example I have tried:
# Basic libraries
import os
import pandas as pd
import numpy as np
# Visualization libraries
import matplotlib.pyplot as plt
import seaborn as sns
import folium
#import folium.plugins as plugins
from wordcloud import WordCloud
import plotly.express as px
data_dict = {'First':[100, 90, np.nan, 95],
'Second': [30, 45, 56, np.nan],
'Third':[np.nan, 40, 80, 98]}
#reating a dataframe from list
df1 = pd.DataFrame(data_dict)
#first_try_with_column_name
df1.loc[:,'First'] = df1.loc[:,'First'].fillna(method='ffill', inplace=True)
#Second_try_Using_List_of_Columns
list_columns = ['First','Second','Third']
df1.loc[:,list_columns] = df1.loc[:,list_columns].fillna(value, inplace=True)
df1
As shown, I used multiple ways to understand the reason behind this issue, so I tried to use the column name, and then I used a list of column names, but unfortunately, the issue is the same.
Is there any recommendation, please?