<jupyter_start><jupyter_text>Practice Data Analysis in Jupyter NotebookPractice python data analysis libraries- pandas, numpy, matplotlib taught in CSE445 class.<jupyter_code>pwd
# only need this line in jupyter
%matplotlib inline

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
dataframe = pd.read_csv('../practice_datasets/vgsales.csv')
dataframe.shape<jupyter_output><empty_output><jupyter_text>Analyzing the dataset<jupyter_code>dataframe.head()
dataframe.describe() # describes only numerical attributes
dataframe.info()
# filter dataframe by column values
genre_options = ['Sports', 'Role-Playing']

filtered_dataframe = dataframe[ (dataframe['Genre'].isin(genre_options)) & (dataframe['Year'] >= 2000) ]

filtered_dataframe.head()<jupyter_output><empty_output><jupyter_text>Visualizing the dataset using statistical graphs<jupyter_code>dataframe['Year'].hist(bins = 50, figsize = (5, 5))
plt.show()
dataframe.plot(
    # general parameters
    kind = 'scatter', x = 'Global_Sales', y = 'Genre',     
    # extra attribute with color
    c = 'Year', colorbar = True, cmap = plt.get_cmap('autumn'), 
    # plot properties
    grid = True, title = 'Scatter plot', figsize = (15, 10)
)

plt.show()
# boxplot using pandas
dataframe.boxplot(['Global_Sales', 'JP_Sales', 'EU_Sales'])
plt.show()
# method to setup box_plot using matplotlib
def setup_box_plot(datalist1, datalist2, datalist3, 
               datalist1Label = 'data1', datalist2Label = 'data2', datalist3Label = 'data3'):
    
    box_plot_data = [datalist1, datalist2, datalist3]
    box_plot_labels = [datalist1Label, datalist2Label, datalist3Label]

    # configure the figure size
    fig = plt.figure(figsize =(10, 5))
    fig.suptitle('Box plot')

    box_plot = plt.boxplot(
                    box_plot_data,
                    vert=False,  # horizontal box alignment
                    patch_artist=True,  # fill with color
                    labels=box_plot_labels
                )

    # fill with colors
    colors = ['pink', 'lightblue', 'lightgreen']
    for patch, color in zip(box_plot['boxes'], colors):
            patch.set_facecolor(color)
            
setup_box_plot(
    dataframe['Global_Sales'], dataframe['JP_Sales'], dataframe['EU_Sales'], 
    'Global Sales', 'JP Sales', 'EU Sales'
)

plt.show()
setup_box_plot(
    dataframe['Global_Sales'], dataframe['JP_Sales'], dataframe['EU_Sales'], 
    'Global Sales', 'JP Sales', 'EU Sales'
)   
# clearly view the boxes by editing the x-axis limits
plt.xlim([-0.05, 3])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11964492473948282, 'fraction_numerical': 0.014280200694712466, 'mean_word_length': 4.003861003861004, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '28327', 'license': 'MIT', 'n_tokens_mistral': 907, 'n_tokens_neox': 841, 'n_words': 204, 'path': 'jupyter_notebook/.ipynb_checkpoints/data_analysis_practice_notebook-checkpoint.ipynb', 'repo_name': 'ferdouszislam/CSE445', 'size': '2591'}