0% found this document useful (0 votes)
7 views10 pages

Python Data Visualization Lab Guide

The document outlines a lab work assignment focused on data visualization using Python, specifically through the Seaborn and Plotly libraries. Students are required to explore a unique dataset, formulate hypotheses, and visualize data while adhering to specific report formatting and submission guidelines. The assignment emphasizes the importance of systematic data analysis, interpretation of results, and proper documentation of the process.

Uploaded by

ratan.bhuiyan78
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Python Data Visualization Lab Guide

The document outlines a lab work assignment focused on data visualization using Python, specifically through the Seaborn and Plotly libraries. Students are required to explore a unique dataset, formulate hypotheses, and visualize data while adhering to specific report formatting and submission guidelines. The assignment emphasizes the importance of systematic data analysis, interpretation of results, and proper documentation of the process.

Uploaded by

ratan.bhuiyan78
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Data Visualization

Lab Work 1. Data Visualization with Python

Goal of the work:

To learn how to apply data visualization tools in Python to explore a real


dataset, generate analytical hypotheses, and verify them through graphical analysis.

Objectives to achieve the goal:


1. Explore the dataset and describe its subject area.
2. Select appropriate visualization tools and prepare the data for analysis.
3. Formulate at least five hypotheses that can be investigated using visualization
methods.
4. Visualize the data using a justified method from the Seaborn library for
Python and interpret the results.
5. Visualize the data using a justified method from the Plotly library for Python
and interpret the results.

Overall requirements:
1. The work must be completed using Python in a Jupyter Notebook
environment preferably in virtual machine in cloud (for example, Google
Colab or GitHub Codespaces).
2. The assignment is performed individually – each student receives a unique
dataset in CSV format.
3. All results of the work must be presented in a report following the provided
template. The report may be revised up to three times; after the third revision,
the grade becomes final and cannot be changed.
4. Each subsequent laboratory assignment becomes available only after the
student receives a grade for the previous one. The final deadline for submitting
the completed work is the beginning of the examination session.
Recommended reading

1. What is a CSV file? How to open and use the popular spreadsheet file (URL:
[Link]
2. 10 minutes to pandas (URL:
[Link]
3. The Data Visualisation Catalogue (URL: [Link]
4. seaborn: statistical data visualization (URL: [Link]
5. Data Visualization with Seaborn – Python (URL:
[Link]
python-seaborn/)
6. Plotly Open Source Graphing Library for Python (URL:
[Link]
7. Plotly tutorial (URL: [Link]
tutorial/)

Report requirements
The report documents the process and results of your laboratory work.
Students must follow these requirements to ensure clarity, correctness, and full credit.
Failure to comply with these guidelines may reduce the score.

• Goal and objectives

o The report begins with the goal of the work and the list of objectives
exactly as provided in the methodological guide.
• Organization by chapters
o The report is structured into chapters corresponding to the solutions of
individual objectives.
o Chapter titles should reflect the process rather than the exact wording
of the objective.
o Example: Objective “Find and prepare data for analysis” → Chapter
title: “Data Search and Preparation for Analysis.”
• Sequential work
o Tasks must be completed in order, from the first objective to the last.
• Step-by-step documentation
o For each task, describe all actions sequentially, answering the following
questions: Why? – Explain the purpose of the action (“In order to…”)
What? – Describe the action (“We wrote a program…”) How? –
Explain the method or algorithm used (“Using the following
methods…”) and include Result – the output, screenshot with proper
captions.
• Citations and references

o When using external sources or new methods, cite appropriately and


explain new terms or concepts.
o Include a list of References (books, articles, websites) formatted
according to technical norms.
o Do not use Wikipedia or other encyclopedias as sources.
• Formatting
o Follow the provided report template strictly: Main text: Times New
Roman, 14 pt, justified alignment. Code: framed, Courier, 10 pt (or 10.5
pt if copied from IDEs).
o Software names must be written as created by the authors: Python,
Microsoft Excel, etc.
• Language and style
o Do not copy text from the methodological guide.
o Do not use second-person phrases such as “You should…”, “Let’s
do…”, “If you want…”, etc.
o Write in the first person: “We did…”, “I performed…”, “The following
steps were executed…”.
o Incorrect language style or copied text will reduce the score.
• Conclusion
o Provide a general conclusion summarizing the work.
o Include brief conclusions for each objective, reflecting the results of the
analysis.
• Submission file format
o Submit the report electronically in PDF.
o File name format: “Student Name. Group. Data Visualization. Lab
Work #.pdf” Example: “Ivanov Ivan. ЦТм-25-1. Data Visualization.
Lab Work [Link]”
• Template adaptation
o Any text highlighted in yellow in the template must be rewritten
according to the goal, objectives and initial data, and the highlighting
removed.
Methodological part

1. Setup for working in Python (Google Colab)

Before starting the analysis, we need to set up the working environment,


import libraries, and define standard plotting parameters. This simplifies data
visualization and analysis.

We use pandas to work with tabular data, Matplotlib and Seaborn for static
plots, and Plotly for interactive visualizations. Setting a consistent style makes
graphs easier to read and interpret. To install required libraries if not already installed:

!pip install pandas matplotlib seaborn plotly --quiet

2. Loading the dataset

The first step is to load the CSV file into a DataFrame, which allows us to
work with the data in Python. To load data into a pandas DataFrame and use info()
method to show the number of rows, column types, and missing values. This helps
assess the quality of the data and determine which columns need type conversion:

import pandas as pd
data = pd.read_csv('../../data/video_games_sales.csv')
[Link]()
Figure 1 – An output of above code

3. Data type conversion

Some columns detected as object by pandas (Fig. 1) should be converted


explicitly to float or int for correct analysis and plotting. Type conversion is
necessary to perform arithmetic operations, grouping, and plotting without errors.

data['User_Score'] = data['User_Score'].astype('float64')
data['Year_of_Release'] = data['Year_of_Release'].astype('int64')
data['User_Count'] = data['User_Count'].astype('int64')
data['Critic_Count'] = data['Critic_Count'].astype('int64')

4. Handling missing values

Some records may be incomplete. To avoid errors in visualization, we keep


only the rows without missing values. The dropna() method removes rows with
missing values. After cleaning, the dataset is ready for exploratory analysis.

data = [Link]()

5. Inspecting the dataset


After cleaning, let’s look at the first few rows to ensure the data is correct. We
select only the columns we will use in the analysis. This step helps visually confirm
that all relevant columns are correctly prepared for analysis.
useful_cols = [
'Name', 'Platform', 'Year_of_Release', 'Genre', 'Global_Sales',
'Critic_Score', 'Critic_Count', 'User_Score', 'User_Count', 'Rating'
]

data[useful_cols].head()

6. Quick visualization using pandas plot

The simplest way to visualize data in a pandas DataFrame is by using the plot()
function. We group the data by release year and sum the sales. The plot() function
automatically generates a line chart (Fig. 2), allowing us to observe overall sales
trends by year.
sales_data = data[[x for x in [Link] if 'Sales' in x] +
['Year_of_Release']]

sales_data.groupby('Year_of_Release').sum().plot()

[Link]("Total Video Game Sales by Year")


[Link]("Year of Release")
[Link]("Sales (millions)")
[Link]()
Figure 2 – An output of above code

7. Formulating hypotheses

Before creating visualizations, it is important to formulate hypotheses that can


be tested using the data. Hypotheses should be specific and measurable, allowing
you to verify them with visual or statistical analysis. Example Hypothesis:

The distribution of critic scores depends on the platform of video games, and
there may be a bias toward higher or lower ratings on certain platforms.
This hypothesis suggests a relationship between two variables: Platform and
Critic_Score. Visualizing these variables can help identify patterns, trends, or biases
in the data.
Hypotheses can explore relationships between different features (columns) of
the dataset, such as:
• Sales trends across genres or platforms
• Relationship between user scores and critic scores
• Impact of release year on global sales
• Distribution of ratings by genre or platform
• Correlation between user engagement (User_Count) and sales
Each hypothesis should be specific, e.g., “Average user score is higher for
action games than for puzzle games”.

For each hypothesis, you will choose an appropriate visualization method


(Seaborn or Plotly) and interpret the results.

8. Choosing visualization methods


When creating visualizations to test hypotheses, it is important to
systematically select the appropriate method. The following steps provide a general
approach.

At first, we define analytical function which is directly derived from the


hypothesis. Before selecting a chart type, clearly define what you want to analyze
from your hypothesis. Common analytical functions include:

• Comparison — comparing values across categories (e.g., sales by genre)


• Distribution — understanding the distribution of a single variable (e.g., user
scores)
• Relationship / Correlation — examining relationships between two numerical
variables (e.g., critic score vs. user score)
• Composition / Proportion — showing parts of a whole (e.g., sales share by
platform)
• Trend / Time Series — observing changes over time (e.g., yearly sales trends)

Once the analytical function is determined, choose an appropriate chart type.


Next, identify which columns (variables, features) in the dataset correspond to the
x-axis, y-axis, and possibly color, size, or facet parameters. Depending on the
hypothesis, you may need to:
• Filter specific categories or time periods
• Group data and calculate aggregates (sum, mean, median)
• Handle missing values or outliers
9. Interpret the results

After creating a visualization, it is essential to carefully interpret the findings


in the context of your hypothesis. The goal is to answer the question: Does the data
support or refute the hypothesis? Here are the key Points for Interpretation:

• Observe patterns and trends


o Look at the overall shape of the data: increasing, decreasing, stable, or
fluctuating trends.
o For example, a line chart showing sales over time may reveal seasonal
trends or long-term growth.
• Examine central tendency and spread
o For boxplots, histograms, or violin plots, check the median, quartiles,
and range of values.
o Are most values concentrated around a certain point, or is there high
variability?
o Example: If the median critic score is higher for one platform, it may
indicate a bias.
• Identify outliers and anomalies
o Outliers can indicate unusual events, errors in data, or exceptions worth
investigating.
o Consider whether outliers support or contradict your hypothesis.
• Compare groups or categories
o If your hypothesis involves comparing categories (e.g., genres,
platforms), examine differences between them.
o Are the differences large enough to suggest a real effect, or could they
be random variation?
• Check relationships between variables
o For scatter plots or bubble charts, look for correlations: positive,
negative, or no clear trend.
o Determine whether the observed relationship aligns with your
hypothesis.
• Assess data quality and limitations
o Consider whether missing values, small sample sizes, or skewed
distributions might affect your conclusions.
o Be cautious in generalizing results beyond the dataset.
• Draw a conclusion
o Clearly state whether your hypothesis is supported, partially supported,
or refuted.
o Provide reasoning based on what you observed in the plot.
o Example: “The boxplot shows that average critic scores are higher on
Platform A than Platform B, supporting the hypothesis that critic ratings
depend on platform.”
• Optional: suggest further analysis
o If the visualization is inconclusive, suggest additional plots or statistical
tests that could help clarify the result.
o Example: Use a correlation matrix or regression analysis to quantify
relationships.

Writing the interpretation in the report, use complete sentences and clear
explanations. Refer to specific elements of the plot: median lines, outliers, clusters,
trends and avoid vague statements; instead, describe what you actually see in the
data. Keep the interpretation concise but informative – from 3 to 6 sentences per
hypothesis are usually sufficient.

You might also like