text_plain_output_3.png text_plain_output_2.png text_plain_output_1.png
import pandas as pd

traindf = pd.read_csv('/kaggle/input/bigmart-sales-data/Train.csv')
testdf = pd.read_csv('/kaggle/input/bigmart-sales-data/Test.csv')

traindf.dtypes

traindf.describe().round(3)

traindf.isna().sum()

df = pd.concat([traindf, testdf], axis=0)
df.shape
df.isnull().sum()

df = df.dropna(subset=['Item_Weight', 'Outlet_Size', 'Item_Outlet_Sales'])

df_itemwt = df.Item_Weight.value_counts().reset_index().rename(columns={'index': 'Item_Weight', 'Item_Weight': 'Number_Of_Items'})
df_itemwt_sorted = df_itemwt.sort_values(by='Number_Of_Items', ascending=False).head(20).reset_index(drop=True)
df_itemwt_sorted

df.loc[df['Item_Fat_Content'] == 'LF', 'Item_Fat_Content'] = 'Low Fat'
df.loc[df['Item_Fat_Content'] == 'low fat', 'Item_Fat_Content'] = 'Low Fat'
df.loc[df['Item_Fat_Content'] == 'reg', 'Item_Fat_Content'] = 'Regular'
df['Item_Fat_Content'].value_counts()

df_itemfat = df.Item_Fat_Content.value_counts().reset_index().rename(columns={'index': 'Fat_Content', 'Item_Fat_Content': 'Number_of_items'})
df_itemfat

item_type_count = df.groupby('Item_Type').count()['Item_Identifier'].reset_index().rename(columns={'Item_Identifier': 'Number_Of_Items'}).sort_values(by='Number_Of_Items', ascending=False)
item_type_count