<jupyter_start><jupyter_text>Data Analysis Mockup Project What is Data Analysis It is a process of **Inspecting**, **Cleaning**, **transforming**, and **Modeling** Data with the goal of discovering useful information, informing conclusion, and supporting decision-makiing.<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# import datetime as dt
import seaborn as sns
# import pandas.util.testing as tm
from google.colab import files
uploaded = files.upload()
df = pd.read_csv('superstore_dataset2011-2015.csv', encoding = 'unicode_escape', index_col='Row ID', parse_dates=['Order Date', 'Ship Date'])
# parsing Date Column as python Datetime formate
df.head(2)
# Converting Order Date column to pandas datetime object
# pd.to_datetime(df['Order Date'])
# Now lets create Year column accessing year from Order date
df['Year'] = df['Order Date'].dt.year
df.head(1)
df.describe(include='all')
df['Category'].value_counts()
# df.loc[:, df['Category'] == 'Furniture']
df[['Category']]
# I don't know what it is doing!
# dict(df)
df.info()
df.isnull().sum()<jupyter_output><empty_output><jupyter_text>isnull method by default accept axis argument = 0, means axis=0, it indicates any operation through the row direction<jupyter_code>df[df['Postal Code'].isnull()]
# this will return number of all rows where Postal Code is null
df['Ship Mode'].value_counts()
df['Country'].unique() #.tolist()
df['Country'].value_counts()<jupyter_output><empty_output><jupyter_text>Numerical Analysis and Visualization<jupyter_code>df['Sales'].describe()<jupyter_output><empty_output><jupyter_text>Boxplot<jupyter_code>cln_df = df.dropna(how='any')
# df['Sales'].plot(kind='box', vert=False, figsize=(14, 5))
cln_df['Sales'].plot(kind='box', vert=False, figsize=(14, 5))
df['Profit'].describe()
cln_df.info()
df['Profit'].mean()<jupyter_output><empty_output><jupyter_text>Distribution Plot<jupyter_code>sns.distplot(df['Profit'])<jupyter_output><empty_output><jupyter_text>Density Plot<jupyter_code>var = df['Profit'].plot(kind='density', figsize=(13, 7))
var.set_xlabel('Raw ID')
var.set_ylabel('Profit')
var.axvline(df['Profit'].mean(), color='green')
var.axvline(df['Profit'].median(), color='red')
var2 = df['Sales'].plot(kind='density', figsize=(13, 8))
var2.set_xlabel('Raw ID')
var2.set_ylabel('Sales')
var2.axvline(df['Sales'].mean(), color='green')
var2.axvline(df['Sales'].median(), color='red')<jupyter_output><empty_output><jupyter_text>Inabove way we plotting directly using pandas<jupyter_code>plt.scatter(df['Sales'], df['Profit'])
df['Category'].value_counts().plot(kind='pie', figsize=(8,8))
df['Category'].value_counts().plot(kind='bar')
corr = df.corr()
corr
# sns.heatmap(df)
corr = df.corr()
fig = plt.figure(figsize=(11,11))
ax = plt.subplot()
ax.matshow(corr)

# fig = plt.figure(figsize=(11,11))
fig = plt.figure(figsize=(11,11))
plt.matshow(corr, cmap='RdBu', fignum=fig.number)
plt.xticks(range(len(corr.columns)), corr.columns, rotation='vertical')
plt.yticks(range(len(corr.columns)), corr.columns)
plt.show()

# Dark blue indicates values are highly positively corelated
# Dark Red indicates values are highly negatively corelated
# Slicing Data Frame
# Accessing all numeric column
sldf = df.iloc[:, 17:].head()
# ax = sns.heatmap(sldf)
sldf
df.info()
cln_df.head()
# cln_df['Region'].value_counts().plot(kind='bar')

south_region = cln_df.loc[df['Region']=='South']
south_region.head(1)<jupyter_output><empty_output><jupyter_text>Number of unique values in ['Region'] column<jupyter_code>cln_df['Region'].value_counts().plot(kind='bar', color='red')
len(south_region)
south_region = len(cln_df.loc[cln_df['Region'] == 'South'])
central_region = len(cln_df.loc[cln_df['Region'] == 'Central'])
east_region = len(cln_df.loc[cln_df['Region'] == 'East'])
west_region = len(cln_df.loc[cln_df['Region'] == 'West'])
print(f"Parcent of Sales in West Region: {round((west_region/(west_region+east_region+central_region+south_region)*100), 2)} % - Number of Sales: {west_region}")
print(f"Parcent of Sales in East Region: {round((east_region/(west_region+east_region+central_region+south_region)*100),2)} % - Number of Sales: {east_region}")
print(f"Parcent of Sales in Central Region: {round((central_region/(west_region+east_region+central_region+south_region)*100), 2)} % - Number of Sales: {central_region}")
print(f"Parcent of Sales in South Region: {round((south_region/(west_region+east_region+central_region+south_region)*100), 2)} % - Number of Sales: {south_region}")
cln_df['Discount']*=2
cln_df[['Discount']].head()<jupyter_output><empty_output><jupyter_text>Inserting second dataset<jupyter_code>from google.colab import files
uploaded2= files.upload()
df2 = pd.read_csv('sales_data_sample.csv', encoding = 'unicode_escape')
df2.describe(include='all')
len(df2)
df2.info()
df2['PRODUCTLINE'].unique().tolist()<jupyter_output><empty_output><jupyter_text>Generating Random Number Using Numpy and then plot those number using matplotlib<jupyter_code>x = np.linspace(0, 10, 500)
y = np.cumsum(np.random.randn(500, 6), 0)
# len(y)
type(x)
len(x)<jupyter_output><empty_output><jupyter_text>Ploting those Random Number<jupyter_code>plt.figure(figsize=(16,8))
plt.plot(x, y)
plt.grid()
plt.legend('ABCDEF', ncol=2, loc='upper left')
cov = df2.corr()
cov
df2.tail(2)<jupyter_output><empty_output><jupyter_text>Inserting Data using pandas loc[index] attributes length of df2 is 2823, 0 to 2822every colum in dataframe represents aseries object which is one dimentional array<jupyter_code>df2.loc[2823] = [1110909,	49,	101.00,	14,	52005.27,	'',	
                 'Shipped',	4,	10,	2003,	'Motorcycles',	95,	'S10_1678',	
                 'Corporate Gift Ideas CA',	'6505551386', '7734 Strong St.',	'',	
                 'San Francisco',	'CA',	'',	'USA',	'',	'Abid', 'Shafekul',	'Medium']
df2.loc[2823]
df2.tail()
from bokeh.plotting import figure, output_file, show
from bokeh.io import output_notebook
output_notebook()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16583082581076564, 'fraction_numerical': 0.026746907388833167, 'mean_word_length': 7.747076023391813, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '666948', 'license': 'Apache-2.0', 'n_tokens_mistral': 2308, 'n_tokens_neox': 2147, 'n_words': 443, 'path': 'dataAnalysis.ipynb', 'repo_name': 'abidshafee/dataAnalysis', 'size': '5982'}