text_plain_output_1.png
import pandas as pd

df1 = pd.read_csv('/kaggle/input/walmart-sales-analysis/Walmart.csv', index_col='Order ID')

df1.shape

df1.columns

df1['Order Date'] = pd.to_datetime(df1['Order Date'])
df1['Ship Date'] = pd.to_datetime(df1['Ship Date'])

df1.nunique()

df1.isna().sum()

df1['Profit/Unit'] = df1['Profit'] / df1['Quantity']
df1['Price'] = df1['Sales'] / df1['Quantity']
df1['Cost Per Unit'] = df1['Price'] - df1['Profit/Unit']
df1.sample(3)

df1['Month'] = df1['Order Date'].dt.month
df1.sample(3)

b = df1.groupby(['Month', 'State'])['Sales'].sum()
v = df1.groupby(['Month', 'State'])['Profit'].sum()
v1 = pd.merge(b, v, how='left', on=['Month', 'State'])
v1.reset_index
v1 = pd.DataFrame(v1)
v1.reset_index(inplace=True)
v1

u = df1.groupby('Category')['Profit'].sum()
u