Dev Notes
Dev Notes
OF
(2025-26)
PREPARED BY
COURSE OBJECTIVES:
UNIT I
Introduction to Data Visualization, Key factors of Data Visualization, Importance of Data
Visualization in Business Intelligence, Data Visualization tools and types of data, Data
Abstraction: data types, dataset types, Attribute types, Task Abstraction, Four Levels for
Validation.
UNIT II
Visualization Techniques: Scalar and point visualizations, – vector visualizations –
multidimensional visualizations – Cluster Visualizations – matrix visualization in Bayesian data
analysis
UNIT III
Getting Started with Pandas: Arrays and vectorized computation, Introduction to pandas Data
Structures, Essential Functionality, Summarizing and Computing Descriptive Statistics. Data
Loading, Storage and File Formats. Reading and Writing Data in Text Format, Web Scraping,
Binary Data Formats, Interacting with Web APIs, Interacting with Databases Data Cleaning and
Preparation. Handling Missing Data, Data Transformation, String Manipulation
REFERENCE BOOKS:
1. Introduction to Data Science a Python approach to concepts, Techniques and Applications,
Igual, L;Seghi’, S. Springer, ISBN:978-3-319-50016-4.
2. ALL-IN-ONE-EXCEL 2022 Bible for Dummies by Bryant Shelton
3. Excel® 2019 BIBLE BY Michael Alexander, Dick Kusleika
4. Python for Data Analysis by William McKinney, Second Edition, O’Reilly MediaInc.
COURSE OUTCOMES:
Introduction
In our increasingly data-driven world, it’s more important than ever to have accessible ways to
view and understand data. After all, the demand for data skills in employees is steadily
increasing each year. Employees and business owners at every level need to have an
understanding of data and of its impact.
That’s where data visualization comes in handy. With the goal of making data more accessible
and understandable, data visualization in the form of dashboards is the go-to tool for many
businesses to analyze and share information.
Data visualization is the graphical representation of information and data. By using visual
elements like charts, graphs, and maps, data visualization tools provide an accessible way to
see and understand trends, outliers, and patterns in data. Additionally, it provides an excellent
way for employees or business owners to present data to non-technical audiences without
confusion.
Data visualization is the practice of translating information into a visual context, such as a map
or graph, to make data easier for the human brain to understand and pull insights from. The
main goal of data visualization is to make it easier to identify patterns, trends and outliers in
large data sets. The term is often used interchangeably with others, including information
graphics, information visualization and statistical graphics.
Data visualization is one of the steps of the data science process, which states that after data
has been collected, processed and modelled, it must be visualized for conclusions to be made.
Data visualization is also an element of the broader data presentation architecture (DPA)
discipline, which aims to identify, locate, manipulate, format and deliver data in the most
efficient way possible.
Data visualization is important for almost every career. It can be used by teachers to display
student test results, by computer scientists exploring advancements in artificial intelligence
(AI) or by executives looking to share information with stakeholders. It also plays an important
role in big data projects. As businesses accumulated massive collections of data during the
early years of the big data trend, they needed a way to get an overview of their data quickly
and easily. Visualization tools were a natural fit.
Visualization is central to advanced analytics for similar reasons. When a data scientist is
writing advanced predictive analytics or machine learning (ML) algorithms, it becomes
important to visualize the outputs to monitor results and ensure that models are performing as
intended. This is because visualizations of complex algorithms are generally easier to interpret
than numerical outputs.
1
Why is data visualization important?
✓ the ability to absorb information quickly, improve insights and make faster decisions;
✓ an increased understanding of the next steps that must be taken to improve the
organization;
✓ an improved ability to maintain the audience's interest with information they can
understand;
✓ an easy distribution of information that increases the opportunity to share insights with
everyone involved;
✓ eliminate the need for data scientists since data is more accessible and understandable;
and
✓ an increased ability to act on findings quickly and, therefore, achieve success with
greater speed and less mistakes.
In today's world, a huge amount of data is generated every day and it is very important to
visualize the data to know its pattern to make important business decisions. At its core, effective
data visualization relies on several key components, each playing a crucial role in conveying
information accurately and efficiently. These components encompass aspects ranging from the
choice of visual representation to the use of colour, interactivity, and storytelling techniques.
Data visualization is a crucial part of data analytics that helps you visualize your data and
uncover significant trends and patterns
2
Understanding these components is essential for creating compelling and informative
visualizations that facilitate data-driven decision-making across various domains. In this
article, we will learn about What are the key components of data visualization?
1. Data: First of all we need lots of data. Data can be of any type like numerical data, text
data or geospatial data.
2. Visual Elements: For instance, Graphics, charts, Overlays, diagrams, figures, maps,
tables and other types of data presentations and resumes that comprise infographics.
3. Visualization Techniques: This also includes aspects such as transforming and scaling
data, and in some cases indeed selecting the right type of visualization to use.
5. Color Palette and Design: New choices on color utilization, font selection, position of
elements in unison with the style of design to enhance the usability, visibility and the
aesthetic appeal of visualization.
6. Context and Annotations: The additional roles of Titles and Subtitles in the
Visualizations and some of the other labels for captions, annotations and legends for
further understanding of the analysis.
7. Tools and Platforms: Software that falls under "Other Tools and Applications while
developing visualization" Some of the prominent ones are Tableau, Power BI and more
programming languages and Libraries are D3. js ,Matplotlib and more.
8. Data Preparation: Data preparation which involves cleaning of data, that is, data
cleaning processing, data selection, data reshaping and data condensation that gets a
data in the right form so that it can be analyzed and visualized.
9. Data Exploration: Simple methods for analyzing the data for searching the pattern,
trend, noise, similarity and correlation other than the techniques.
10. Dashboarding: An aggregate display of the two screens to give an overall view of the
data collected as well as endlessly monitoring the indicators by having the two tabbed
views on the same screen.
3
1.3 IMPORTANCE OF DATA VISUALIZATION IN BUSINESS INTELLIGENCE
Data visualization is technique for businesses. It helps them understand their data better, make
smarter decisions, and stay ahead of the competition. It basically turns boring numbers into
easy-to-understand pictures or graphs, helping businesses see what's going on and what they
need to do next.
1. Simplifies Data for Better Understanding: Data visualization makes complex and raw
data easy to understand by displaying it in the form of graphs and charts. This helps us
see patterns and important information more clearly.
2. Help Us Make Better Decisions: When we can see our data in pictorial form or graphs
and chart, it's easier to make smart decisions quickly.
3. Helps In Visualizing Data Easily: Even the people who are not experts in data can
understand data easily with the help of visualization. Non-technical people can also
understand the data easily with the help of visualization tools, in the form of graphs and
charts.
4. Makes Data More Interesting: Visualizations make data more interesting and fun to
look at, which encourages more people to use data to help their work.
5. Helps in Tracking Progress: Visual dashboards keeps the track of our progress. They
help us see if we're reaching our goals by giving us a clear picture of our progress.
Data visualization tools are cloud-based applications that help you to represent raw data in
easy-to-understand graphical formats. You can use these programs to produce customizable
bar charts, pie charts, column charts, and more
There are many tools that are used for data visualization. Some of the tools are discussed below
1) Power BI
Power BI is a Business Intelligence and Data Visualization tool which helps you to convert
data from various data sources into interactive dashboards and reports. It provides multiple
software connectors and services.
4
2) Tableau
Tableau is a robust tool for visualizing data in a better way. You can connect any database to
create understandable visuals. It is one of the best visualization tools that enables you to share
visualization with other people.
3) Qlik
Qlik is a data visualization software which is used for converting raw data into knowledge.
This software acts like a human brain which works on “association” and can go into any
direction to search the answers.
• QlikView and Qlik Sense are data visualization and business intelligence tools
developed by Qlik.
• They allow users to create interactive visualizations, dashboards, and reports using data
from multiple sources.
• QlikView helps us to understand complex trends, patterns and convert it itno actionable
insights.
• Qlik Sense is more modern and user-friendly compared to QlikView.
• Google Data Studio is a free data visualization tool that allows users to create interactive
dashboards and reports.
• It is a dashboard and reporting tool that is easy to use, customize and share.
• It integrates seamlessly with other Google products such as Google Analytics, Google
Sheets, and Google BigQuery.
Types of data
1. Nominal data
2. Ordinal data
3. Discrete data
4. Continuous data
Further, we can classify these data as follows:
5
Qualitative or Categorical Data
Qualitative data, also known as the categorical data, describes the data that fits into the
categories. Qualitative data are not numerical. The categorical information involves categorical
variables that describe the features such as a person’s gender, home town etc. Categorical
measures are defined in terms of natural language specifications, but not in terms of numbers.
Sometimes categorical data can hold numerical values (quantitative value), but those values do
not have a mathematical sense. Examples of the categorical data are birthdate, favourite sport,
school postcode. Here, the birthdate and school postcode hold the quantitative value, but it does
not give numerical meaning.
Nominal Data
Nominal data is one of the types of qualitative information which helps to label the variables
without providing the numerical value. Nominal data is also called the nominal scale. It cannot
be ordered and measured. But sometimes, the data can be qualitative and quantitative.
Examples of nominal data are letters, symbols, words, gender etc.
The nominal data are examined using the grouping method. In this method, the data are grouped
into categories, and then the frequency or the percentage of the data can be calculated. These
data are visually represented using the pie charts.
Ordinal Data
Ordinal data/variable is a type of data that follows a natural order. The significant feature of
the nominal data is that the difference between the data values is not determined. This variable
is mostly found in surveys, finance, economics, questionnaires, and so on. The ordinal data is
commonly represented using a bar chart. These data are investigated and interpreted through
many visualisation tools. The information may be expressed using tables in which each row in
the table shows a distinct category.
6
Quantitative data is also known as numerical data which represents the numerical value (i.e.,
how much, how often, how many). Numerical data gives information about the quantities of a
specific thing. Some examples of numerical data are height, length, size, weight, and so on.
Quantitative data can be classified into two different types based on the data sets. The two
different classifications of numerical data are discrete data and continuous data.
Discrete Data
Discrete data can take only discrete values. Discrete information contains only a finite number
of possible values. Those values cannot be subdivided meaningfully. Here, things can be
counted in whole numbers.
Continuous Data
Continuous data is data that can be calculated. It has an infinite number of probable values that
can be selected within a given specific range.
7
1.5 DATA ABSTRACTION
Data abstraction is the process of structuring, categorizing, and interpreting raw data into
meaningful forms that can be effectively visualized and analyzed.
1. Data Types
2. Dataset Types
• Tables: 2D representation; rows = items, columns = attributes.
• Networks: Nodes (items) connected via links (relationships).
• Fields: Continuous domain data sampled at discrete points.
• Geometry: Describes shape, structure, and spatial layout (points, surfaces, volumes).
• Other: Clusters, sets, and lists that group or categorize items.
3. Attribute Types
4. Direction of Ordering
• Sequential: One-way progression (e.g., 0 to 100).
• Diverging: Ranges from a central baseline in two directions (e.g., temperature above
and below zero).
• Cyclic: Repeats in cycles (e.g., months of the year, clock time).
5. Data Semantics
Data Types:
Figure 2.2 shows the five basic data types discussed they are: items, attributes, links, positions,
and grids. An attribute is some specific property that can be measured, observed, or logged.
For example, attributes could be salary, price, number of sales, protein expression levels, or
8
temperature. An item is an individual entity that is discrete, such as a row in a simple table or
a node
in a network. For example, items may be people, stocks, coffee shops, genes, or cities. A link
is a relationship between items, typically within a network. A grid specifies the strategy for
sampling continuous data in terms of both geometric and topological relationships between its
cells. A position is spatial data, providing a location in two-dimensional (2D) or three-
dimensional (3D) space. For example, a position might be a latitude–longitude pair describing
a location on the Earth’s surface or three numbers specifying a location within the region of
space measured by a medical scanner.
Dataset Types
A dataset is any collection of information that is the target of analysis. The four basic dataset
types are tables, networks, fields, and geometry. Other ways to group items together include
clusters, sets, and lists. In real-world situations, complex combinations of these basic types are
common.
Figure 2.3 shows that these basic dataset types arise from combinations of the data types of
items, attributes, links, positions, and grids.
Figure 2.4 shows the internal structure of the four basic dataset types in detail. Tables have
cells indexed by items and attributes, for either the simple flat case or the more complex
multidimensional case. In a network, items are usually called nodes, and they are connected
with links; a special case of networks is trees. Continuous fields have grids based on spatial
positions where cells contain attributes. Spatial geometry has only position information.
9
Tables:
Many datasets come in the form of tables that are made up of rows and columns, a familiar
form to anybody who has used a spreadsheet. In this chapter, I focus on the concept of a table
as simply a type of dataset that is independent of any particular visual representation; later
chapters address the question of what visual representations are appropriate for the different
types of datasets.
For a simple flat table, the terms used in this book are that each row represents an item of data,
and each column is an attribute of the dataset. Each cell in the table is fully specified by the
combination of a row and a column—an item and an attribute—and contains a value for that
pair. Figure 2.5 shows an example of the first few dozen items in a table of orders, where the
attributes are order ID, order date, order priority, product container, product base margin, and
ship date.
A multidimensional table has a more complex structure for indexing into a cell, with multiple
keys.
10
Networks and Trees
The dataset type of networks is well suited for specifying that there is some kind of
relationship between two or more items. An item in a network is often called a node. A link
is a relation between two items. For example, in an articulated social network the nodes are
people, and links mean friendship.
In a gene interaction network, the nodes are genes, and links between them mean that these
genes have been observed to interact with each other. In a computer network, the nodes are
computers, and the links represent the ability to send messages directly between two
computers using physical cables or a wireless connection.
Network nodes can have associated attributes, just like items in a table. In addition, the links
themselves could also be considered to have attributes associated with them; these may be
partly or wholly disjointed from the node attributes. It is again important to distinguish between
the abstract concept of a network and any particular visual layout of that network where the
nodes and edges have particular spatial positions. This chapter concentrates on the former.
Trees: Networks with hierarchical structure are more specifically called trees. In contrast to a
general network, trees do not have cycles: each child node has only one parent node pointed to
it. One example of a tree is the organization chart of a company, showing who reports to whom;
another example is a tree showing the evolutionary relationships between species in the
biological tree of life, where the child nodes of humans and monkeys both share the same
parent node of primates.
Fields: The field dataset type also contains attribute values associated with cells.1 Each cell in
a field contains measurements or calculations from a continuous domain: there are
conceptually infinitely many values that you might measure, so you could always take a new
measurement between any two existing ones. Continuous phenomena that might be measured
in the physical world or simulated in software include temperature, pressure, speed, force, and
density; mathematical functions can also be continuous. For example, consider a field dataset
representing a medical scan of a human body containing measurements indicating the
density of tissue at many sample points, spread regularly throughout a volume of 3D space. A
low-resolution scan would have 262,144 cells, providing information about a cubical volume
of space with 64 bins in each direction. Each cell is associated with a specific region in 3D
space. The density measurements could be taken closer together with a higher resolution grid
of cells, or further apart for a coarser grid.
Continuous data requires careful treatment that takes into account the mathematical questions
of sampling, how frequently to take the measurements, and interpolation, how to show values
in between the sampled points in a way that does not mislead. Interpolating appropriately
between the measurements allows you to reconstruct a new view of the data from an arbitrary
viewpoint that’s faithful to what you measured. These general mathematical
problems are studied in areas such as signal processing and statistics. Visualizing fields
requires grappling extensively with these concerns. In contrast, the table and network datatypes
11
discussed above are an example of discrete data where a finite number of individual items
exist, and interpolation between them is not a meaningful concept. In the cases where a
mathematical framework is necessary, areas such as graph theory and combinatorics provide
relevant ideas.
Spatial Fields: Continuous data is often found in the form of a spatial field, where the cell
structure of the field is based on sampling at spatial positions. Most datasets that contain
inherently spatial data occur in the context of tasks that require understanding aspects of its
spatial structure, especially shape.
For example, with a spatial field dataset that is generated with a medical imaging instrument,
the user’s task could be to locate suspected tumors that can be recognized through distinctive
shapes or densities. An obvious choice for visual encoding would be to show something that
spatially looks like an X-ray image of the human body and to use color coding to highlight
suspected tumors. Another example is measurements made in a real or simulated wind tunnel
of the temperature and pressure of air flowing over airplane wings at many points in 3D space,
where the task is to compare the flow patterns in different regions. One possible visual encoding
would use the geometry of the wing as the spatial substrate, showing the temperature and
pressure using size-coded arrows.
The likely tasks faced by users who have spatial field data constrains many of the choices about
the use of space when designing visual encoding idioms. Many of the choices for nonspatial
data, where no information about spatial position is provided with the dataset, are unsuitable
in this case. Thus, the question of whether a dataset has the type of a spatial field or a nonspatial
table has extensive and far-reaching implications for idiom design. Historically, vis diverged
into areas of specialization based on this very differentiation. The subfield of scientific
visualization, or scivis for short, is concerned with situations where spatial position is given
with the dataset. A central concern in scivis is handling continuous data appropriately within
the mathematical framework of signal processing. The subfield of information visualization,
or infovis for short, is concerned with situations where the use of space in a visual encoding is
chosen by the designer. A central concern in infovis is determining whether the chosen idiom
is suitable for the combination of data and task, leading to the use of methods from human–
computer interaction and design.
Grid Types
When a field contains data created by sampling at completely regular intervals, as in the
previous example, the cells form a uniform grid. There is no need to explicitly store the grid
geometry in terms of its location in space, or the grid topology in terms of how each cell
connects with its neighbouring cells. More complicated examples require storing different
amounts of geometric and topological information about the underlying grid. A rectilinear grid
supports nonuniform sampling, allowing efficient storage of information that has high
complexity in some areas and low complexity in others, at the cost of storing some information
about the geometric location of each row. A structured grid allows curvilinear shapes, where
the geometric location of each cell needs to be specified. Finally, unstructured grids provide
12
complete flexibility, but the topological information about how the cells connect to each other
must be stored explicitly in addition to their spatial positions.
Geometry
The geometry dataset type specifies information about the shape of items with explicit spatial
positions. The items could be points, or one-dimensional lines or curves, or 2D surfaces or
regions, or 3D volumes.
Geometry datasets are intrinsically spatial, and like spatial fields they typically occur in the
context of tasks that require shape understanding. Spatial data often includes hierarchical
structure at multiple scales. Sometimes this structure is provided intrinsically with the dataset,
or a hierarchy may be derived from the original data.
Geometry datasets do not necessarily have attributes, in contrast to the other three basic dataset
types. Many of the design issues in vis pertain to questions about how to encode attributes.
Purely geometric data is interesting in a vis context only when it is derived or transformed in a
way that requires consideration of design choices. One classic example is when contours are
derived from a spatial field. Another is when shapes are generated at an appropriate level of
detail for the task at hand from raw geographic data, such as the boundaries of a forest or a city
or a country, or the curve of a road. The problem of how to create images from a geometric
description of a scene falls into another domain: computer graphics. While vis draws on
algorithms from computer graphics, it has different concerns from that domain. Simply
showing a geometric dataset is not an interesting problem from the point of view of a vis
designer.
Other Combinations
Beyond tables, there are many ways to group multiple items together, including sets, lists, and
clusters. A set is simply an unordered group of items. A group of items with a specified ordering
could be called a list. A cluster is a grouping based on attribute similarity, where items within
a cluster are more similar to each other than to ones in another cluster.
There are also more complex structures built on top of the basic network type. A path through
a network is an ordered set of segments formed by links connecting nodes. A compound
network is a network with an associated tree: all of the nodes in the network are the leaves of
the tree, and interior nodes in the tree provide a hierarchical structure for the nodes that is
different from network links between them.
Many other kinds of data either fit into one of the previous categories or do so after
transformations to create derived attributes. Complex and hybrid combinations, where the
complete dataset contains multiple basic types, are common in real-world applications.
The set of basic types presented above is a starting point for describing the what part of an
analysis instance that pertains to data; that is, the data abstraction. In simple cases, it may be
possible to describe your data abstraction using only that set of terms. In complex cases, you
may need additional description as well. If so, your goal should be to translate domain-specific
terms into words that are as generic as possible.
13
Attribute Types
Figure 2.7 shows the attribute types. The major distinction is between categorical versus
ordered. Within the ordered type is a further differentiation between ordinal versus quantitative.
Ordered data might range sequentially from a minimum to a maximum value, or it might
diverge in both directions from a zero point in the middle of a range, or the values may wrap
around in a cycle. Also, attributes may have hierarchical structure.
Categorical
The first distinction is between categorical and ordered data. The type of categorical data, such
as favorite fruit or names, does not have an implicit ordering, but it often has hierarchical
structure. Categories can only distinguish whether two things are the same (apples) or different
(apples versus oranges). Of course, any arbitrary external ordering can be imposed upon
categorical data. Fruit could be ordered alphabetically according to its name, or by its price—
but only if that auxiliary information were available. However, these orderings are not implicit
in the attribute itself, the way they are with quantitative or ordered data. Other examples of
categorical attributes are movie genres, file types, and city names.
All ordered data does have an implicit ordering, as opposed to unordered categorical data.
This type can be further subdivided. With ordinal data, such as shirt size, we cannot do full-
fledged arithmetic, but there is a well-defined ordering. For example, large minus medium is
not a meaningful concept, but we know that medium falls between small and large. Rankings
14
are another kind of ordinal data; some examples of ordered data are top-ten lists of movies or
initial lineups for sports tournaments depending on past performance.
Ordered data can be either sequential, where there is a homogeneous range from a minimum
to a maximum value, or diverging, which can be deconstructed into two sequences pointing in
opposite directions that meet at a common zero point. For instance, a mountain height dataset
is sequential, when measured from a minimum point of sea level to a maximum point of Mount
Everest. A bathymetric dataset is also sequential, with sea level on one end and the lowest point
on the ocean floor at the other. A full elevation dataset would be diverging, where the values
go up for mountains on land and down for undersea valleys, with the zero value of sea level
being the common point joining the two sequential datasets.
Cyclic
Ordered data may be cyclic, where the values wrap around back to a starting point rather than
continuing to increase indefinitely. Many kinds of time measurements are cyclic, including
the hour of the day, the day of the week, and the month of the year.
Task abstraction refers to the systematic way of categorizing user goals and actions when
interacting with visualized data. It helps designers understand what users want to do with the
data and guides the selection of appropriate visualization techniques.
1. Actions
High-Level Actions
15
Mid-Level Actions
Low-Level Actions
2. Targets
3. Attributes
4. Data Types
17
As shown on the figure above, there are four nested levels of vis design, including domain
situation, task and data abstraction, visual encoding and interaction idiom, and algorithm. Each
level has different threats to validity, and validation approaches should be chosen accordingly.
In addition, these four levels are nested. That means the output from an upstream level above
is input to the downstream level below. A block is the outcome of the design process at that
level.
Domain Situation
Blocks at this top level describe a specific domain situation, which encompasses a group of
target users, their domain of interest, their questions, and their data. The term domain is
frequently used in the vis literature to mean a particular field of interest of the target users of a
vis tool, for example microbiology or high-energy physics or e-commerce. Each domain
usually has its own vocabulary for describing its data and problems, and there is usually some
existing workflow of how the data is used to solve their problems. The group of target users
might be as narrowly defined as a handful of people working at a specific company, or as
broadly defined as anybody who does scientific research. One example of a situation block is
a computational biologist working in the field of comparative genomics, using genomic
sequence data to ask questions about the genetic source of adaptively in a species. While one
kind of situation is a specific set of users whose questions about their data arise from their
work, situations arise in other contexts. For example, another situation is members of the
general public making medical decisions about their healthcare in the presence of uncertainty
At this level, situation blocks are identified: the outcome of the design process is an
understanding that the designer reaches about the needs of the user. The methods typically used
by designers to identify domain situation blocks include interviews, observations, or careful
research about target users within a specific domain.
Design at the next level requires abstracting the specific domain questions and data from the
domain-specific form that they have at the top level into a generic representation. Abstracting
into the domain-independent vocabulary allows you to realize how domain situation blocks
that are described using very different language might have similar reasons why the user needs
the vis tool and what data it shows.
Questions from very different domain situations can map to the same abstract vis tasks.
Examples of abstract tasks include browsing, comparing, and summarizing. Task blocks are
identified by the designer as being suitable for a particular domain situation block, just as the
situation blocks themselves are identified at the level above.
Abstract data blocks, however, are designed. Selecting a data block is a creative design step
rather than simply an act of identification. While in some cases you may decide to use the data
in exactly the way that it was identified in the domain situation, you will often choose to
transform the original data from its upstream form to something quite different. The data
abstraction level requires you to consider whether and how the same dataset provided by a user
should be transformed into another form. Many vis idioms are specific to a particular data type,
such as a table of numbers where the columns contain quantitative, ordered, or categorical data;
a node–link graph or tree; or a field of values at every point in space. Your goal is to determine
which data type would support a visual representation of it that addresses the user’s problem.
Although sometimes the original form of the dataset is a good match for a visual encoding that
solves the problem, often a transformation to another data type provides a better solution.
Explicitly considering the choices made in abstracting from domain-specific to generic tasks
and data can be very useful in the vis design process. The unfortunate alternative is to do this
abstraction implicitly and without justification. For example, many early web vis papers
implicitly posited that solving the “lost in hyperspace” problem should be done by showing the
searcher a visual representation of the topological structure of the web’s hyperlink connectivity
19
graph. In fact, people do not need an internal mental representation of this extremely complex
structure to find a page of interest. Thus, no matter how cleverly the information was visually
encoded at the idiom design level, the resulting vis tools all incurred additional cognitive load
for the user rather than reducing it.
At the third level, you decide on the specific way to create and manipulate the visual
representation of the abstract data block that you chose at the previous level, guided by the
abstract tasks that you also identified at that level. I call each distinct possible approach an
idiom. There are two major concerns at play with idiom design. One set of design choices
covers how to create a single picture of the data: the visual encoding idiom controls exactly
what users see. Another set of questions involves how to manipulate that representation
dynamically: the interaction idiom controls how users change what they see. For example, the
Word Tree system combines the visual encoding idiom of a hierarchical tree representation of
keywords laid out horizontally, preserving information about the context of their use within the
original text, and the interaction idiom of navigation based on keyword selection. While it’s
often possible to analyze encoding and interaction idioms as separable decisions, in some cases
these decisions are so intertwined that it’s best to consider the outcome of these choices to be
a single combined idiom. Idiom blocks are designed: they are the outcome of decisions that
you make. The design space of static visual encoding idioms is already enormous, and when
you consider how to manipulate them dynamically that space of possibilities is even bigger.
The nested model emphasizes identifying task abstractions and deciding on data abstractions
in the previous level exactly so that you can use them to rule out many of the options as being
a bad match for the goals of the users. You should make decisions about good and bad matches
based on understanding human abilities, especially in terms of visual perception and memory.
While it’s common for vis tools to provide multiple idioms that users might choose between,
some vis tools are designed to be very narrow in scope, supporting only a few or even just a
single idiom.
20
Figure 4.3. Word Tree combines the visual encoding idiom of a hierarchical tree of keywords
laid out horizontally and the interaction idiom of navigation based on keyword selection.
Algorithm
The innermost level involves all of the design choices involved in creating an algorithm: a
detailed procedure that allows a computer to automatically carry out a desired goal. In this case,
the goal is to efficiently handle the visual encoding and interaction idioms that you chose in
the previous level. Algorithm blocks are also designed, rather than just identified.
You could design many different algorithms to instantiate the same idiom. For example, one
visual encoding idiom for creating images from a three-dimensional field of measurements,
such as scans created for medical purposes with magnetic resonance imaging, is direct volume
rendering. Many different algorithms have been proposed as ways to achieve the requirements
of this idiom, including ray casting, splatting, and texture mapping. You might
determine that some of these are better than others according to measures such as the speed of
the computation, how much computer memory is required, and whether the resulting image is
an exact match with the specified visual encoding idiom or just an approximation.
The nested model emphasizes separating algorithm design, where your primary concerns are
about computational issues, from idiom design, where your primary concerns are about human
perceptual issues.
Of course, there is an interplay between these levels. For example, a design that requires
something to change dynamically when the user moves the mouse may not be feasible if
computing that would take minutes or hours instead of a fraction of a second. However, clever
algorithm design could save the day if you come up with a way to precompute data that supports
a fast enough response.
21
Unit – II
Visualization Techniques: Scalar and point techniques, – vector visualization techniques –
multidimensional techniques – visualizing cluster analysis – matrix visualization in Bayesian data
analysis
Data visualization transforms raw numbers into actionable insights. Whether you’re analyzing
household power consumption, weather patterns, or financial trends, the right visualization
technique can reveal hidden patterns that tables of numbers never could.
✔ Scalar & Point Techniques (single-value data like temperature or power usage).
✔ Vector Visualization (direction + magnitude, like electrical current flow).
✔ Multi-dimensional Methods (complex datasets with many variables).
We’ll use the UCI Household Power Consumption Dataset to demonstrate real-world
applications.
22
Conversion of Data txt File to CSV File and Load it For Processing
Scalar visualization deals with data where each point in a dataset has a single numerical value
associated with it. This value, or “scalar,” represents a magnitude or intensity of a particular
property at that location. The goal of scalar visualization is to effectively communicate the
distribution and variation of this single value across the dataset.
Heatmaps are powerful data visualization tools that use color intensity to represent the
magnitude of a value across a two-dimensional grid or matrix. They provide an immediate and
intuitive way to identify patterns, correlations, and anomalies within large datasets, making
trends and insights visible “at a glance.”
• High values are represented by warmer colors (like red, orange, yellow).
• Low values are represented by cooler colors (like blue, green, purple).
23
B. Time Series (Global Active Power)
The term “Time Series (Global Active Power)” typically refers to a dataset that records the
total active electrical power consumed by a household (or a similar entity) over a period of
time. This data is sequential, with each data point associated with a specific timestamp.
Analyzing this time series can reveal patterns in energy consumption, identify peak usage
periods, and provide insights for energy management and forecasting.
24
C. Multi-Trend Heatmap (Daily & Hourly Power)
A Multi-Trend Heatmap is an extension of the standard heatmap that goes beyond visualizing
a single variable across two dimensions. Instead, it aims to display multiple trends or
variables simultaneously within the same grid, often by employing different visual encodings
for each trend. This allows for the exploration of complex relationships and correlations
between several factors at a glance.
25
D. Contour Plot (Voltage vs. Time)
A Contour Plot, also known as an isoline plot (for 2D) or isosurface plot (for 3D), is a
graphical technique used to represent a three-dimensional surface by plotting constant z
values (the third dimension) on a two-dimensional plane. In essence, it shows where a
continuous function has the same value.
Imagine slicing through a 3D surface at different constant z-values. The intersection of each
slice with the surface creates a line (in 2D projection) or a surface (which is then projected onto
2D). These lines or projected surfaces connect points of equal value and are called contour
lines or isocontours.
26
E. Horizon Graphs
Horizon Graphs are a space-efficient visualization technique designed to display the trends of
multiple time series data within a limited vertical space while preserving readability and
allowing for easy comparison. They achieve this by folding and layering the time series data
along the vertical axis, using color to differentiate the layers and indicate whether the values
are above or below a baseline (typically zero).
27
F. Hexagonal Binning
28
2.2 VECTOR VISUALIZATIONS
Vector visualization deals with data that has both magnitude and direction at each point in a
dataset. Unlike scalar data, where each point has a single numerical value, vector data
associates each location with a vector, which is typically represented by an arrow. The
properties of the arrow (length and orientation) directly correspond to the magnitude and
direction of the vector at that point.
An Arrow Plot, also known as a Vector Field Plot, is a fundamental vector visualization
technique used to display vector data on a two-dimensional (or sometimes three-dimensional)
plane. It represents the magnitude and direction of a vector at discrete points in a spatial
domain using arrows.
29
B. Streamlines (Sub-metering Relationships)
Streamlines
Streamlines are a type of vector visualization specifically used to depict the instantaneous
direction of a vector field at a given point in time. In the context of fluid flow (which is where
they are most commonly used and understood), a streamline is an imaginary curve that
is everywhere tangent to the instantaneous velocity vector at each point along the curve.
30
31
C. Vector Field Topology
Vector Field Topology is the study and visualization of the qualitative structure of vector
fields. Instead of focusing on the precise magnitude and direction at every point, it aims to
identify and characterize the critical points (singularities) and the invariant
structures (separatrices) that organize the flow or behavior described by the vector field.
Understanding the topology provides a high-level overview of the field’s global behavior and
its key features.
32
2.3 MULTI-DIMENSIONAL VISUALIZATIONS
Multi-Dimensional Visualizations are techniques used to represent datasets with more than
two variables in a single visual display. Since our physical world and typical display devices
are limited to two or three spatial dimensions, these techniques employ various visual encoding
strategies to map additional data dimensions onto visual attributes like position, size, shape,
color, orientation, texture, and animation. The goal is to enable the exploration of complex
relationships, patterns, and correlations that might be hidden when examining variables in
isolation or through simple 2D or 3D plots.
Many real-world datasets are inherently multi-dimensional. For example, a dataset about cars
might include variables like price, fuel efficiency, horsepower, weight, number of cylinders,
safety rating, and origin. To understand how these factors interact and influence each other, we
need visualization methods that can handle more than just two or three of these variables at
once.
33
B. Scatterplot Matrix (SPLOM)
Scatterplot Matrix is a valuable tool for the initial exploration of multi-dimensional data by
visualizing all pairwise relationships between quantitative variables in a grid of scatter plots.
While it has limitations with high dimensionality and only shows pairwise interactions, it
provides a fundamental and intuitive way to identify potential correlations, patterns, and
outliers within a dataset.
34
C. RadViz (Radial Coordinates)
For more information visit : Data Visualization Techniques: From Scalars to Multi-
Dimensional Mastery | by Himanshu Surendra Rajak | May, 2025 | Medium
35
2. 4 CLUSTER VISUALIZATIONS
There are several clustering algorithms available, each with its unique way of grouping data.
Some of the most popular ones include K-means, Hierarchical Clustering, DBSCAN, and
PaCMAP. These algorithms can handle multidimensional data, making them suitable for
complex datasets.
Visualizing these clusters can help us understand the data better. For instance, we can identify
which data points are similar to each other, how they are grouped, and how these groups are
different from each other. This information can be invaluable in many applications, such as
document analysis, spam filtering, and detecting fraudulent activity.
Clustering visualization has a wide range of applications. In document analysis, for example,
clustering can group similar documents together, making it easier to manage and retrieve
information. Visualizing these clusters can further enhance our understanding of the document
corpus.
In marketing and sales, clustering visualization can help understand customer behavior. By
grouping customers based on their purchasing patterns, businesses can tailor their marketing
strategies to target specific customer groups effectively.
Clustering visualization is also used in spam filtering. By clustering emails based on their
content, spam filters can identify and block spam emails more effectively. Visualizing these
clusters can help improve the spam filter's performance by identifying features that distinguish
spam emails from legitimate ones.
There are several techniques for visualizing clustering results. The choice of technique depends
on the nature of the data and the specific requirements of the task at hand. Some common
techniques include scatter plots, dendrograms, and heatmaps.
or three-dimensional data. Dendrograms are used for hierarchical clustering, showing the
hierarchical relationship between clusters. Heatmaps, on the other hand, are useful for
visualizing high-dimensional data, with colors representing different values in the dataset.
36
There are also several tools available for clustering visualization. Python, for instance, offers
libraries like Matplotlib and Seaborn that provide various functions for data visualization.
These libraries can be used to create scatter plots, dendrograms, heatmaps, and more.
In Python's Matplotlib, for example, we can use the scatter function to create a scatter plot of
our data. Each point in the plot represents a data point, and the color of the point indicates its
cluster. This can be a powerful way to visualize the results of our clustering algorithm.
There are several clustering algorithms that are commonly used for visualization. Each of these
algorithms has its strengths and weaknesses, and the choice of algorithm depends on the
specific requirements of your task.
K-means
K-means is a simple and efficient algorithm that partitions the data into K distinct clusters
based on distance to the centroid of the clusters. The algorithm iteratively assigns each data
point to the nearest centroid and recalculates the centroids until the clusters are stable.
However, K-means assumes that clusters are spherical and equally sized, which might not
always be the case in real-world data.
Hierarchical Clustering
Hierarchical clustering creates a tree of clusters, which can be visualized using a dendrogram.
This algorithm can be either agglomerative (bottom-up) or divisive (top-down). Agglomerative
clustering starts with each data point as a separate cluster and merges the closest pairs of
clusters until only one cluster (or K clusters) remain. Hierarchical clustering can capture
complex cluster structures, but it can be slower than K-means for large datasets.
DBSCAN
PaCMAP
clustering visualization is a powerful tool in the field of data analysis and machine learning. It
provides a way to visually represent the structure of data, making it easier to understand and
interpret. By using appropriate clustering algorithms and following best practices for
37
visualization, you can uncover hidden patterns and insights in your data, leading to more
effective decision-making and strategy planning.
In Bayesian data analysis, matrix visualizations are powerful tools for understanding the
structure and relationships between parameters, posterior distributions, and model outputs.
These visualizations are especially useful when dealing with multivariate distributions or
high-dimensional parameter spaces.
These show histograms of marginal posterior distributions along the diagonal and scatterplots
of joint posteriors in the off-diagonal.
Use:
38
2. Correlation Matrix Plot
39
UNIT III
Getting Started with Pandas: Arrays and vectorized computation, Introduction to pandas Data Structures,
Essential Functionality, Summarizing and Computing Descriptive Statistics. Data Loading, Storage and
File Formats. Reading and Writing Data in Text Format, Web Scraping, Binary Data Formats, Interacting
with Web APIs, Interacting with Databases Data Cleaning and Preparation. Handling Missing Data, Data
Transformation, String Manipulation
Pandas is open-source Python library which is used for data manipulation and analysis. It
consists of data structures and functions to perform efficient operations on data. It is well-suited
for working with tabular data such as spreadsheets or SQL tables. It is used in data science
because it works well with other important libraries. It is built on top of the NumPy library as
it makes easier to manipulate and analyze. Pandas is used in other libraries such as:
• Data Cleaning, Merging and Joining: Clean and combine data from multiple sources,
handling inconsistencies and duplicates.
• Handling Missing Data: Manage missing values (NaN) in both floating and non-
floating point data.
• Column Insertion and Deletion: Easily add, remove or modify columns in a
DataFrame.
• Group By Operations: Use "split-apply-combine" to group and analyze data.
• Data Visualization: Create visualizations with Matplotlib and Seaborn, integrated with
Pandas.
Installation of Pandas
If you have Python and PIP already installed on a system, then installation of Pandas is very
easy.
Import Pandas
Once Pandas is installed, import it in your applications by adding the import keyword:
import pandas
40
Example
In Pandas, arrays and vectorized computation allow for efficient and concise data
manipulation, especially when working with large datasets. Here's a clear explanation of these
concepts:
1. Arrays in Pandas
Pandas is built on NumPy, which uses powerful array structures (ndarray). In Pandas:
Each Series or column in a DataFrame is essentially a NumPy array with some added features
(like labels).
import pandas as pd
print(data)
2. Vectorized Computation
import pandas as pd
s = [Link]([1, 2, 3, 4])
On DataFrames:
df = [Link]({
'B': [4, 5, 6]
})
import numpy as np
s = [Link]([1, 2, 3])
Pandas is an open-source Python library used for working with relational or labeled data in an
easy and intuitive way. It provides powerful data structures and a wide range of operations
for manipulating numerical data and time series. Pandas also offers tools for cleaning,
processing and analyzing data efficiently. It is one of the most popular libraries for data
analysis in Python and primarily supports two core data structures
• Series
42
• DataFrame
Series
A Series is a one-dimensional array-like object that can store any data type such as integers,
strings, floats, or even Python objects. It comes with labels (called an index).
Syntax
Parameters:
Explanation: We pass the list a into [Link](a), which converts it into a Series (a column-
like structure) where each item gets a default index starting from 0, automatically assigned by
Pandas.
43
Explanation: We pass the list a into [Link] a, which converts it into a Series (a column-like
structure) where each number gets a default index starting from 0, automatically assigned by
Pandas.
Explanation: We pass the dictionary a into [Link](a), converting keys into index labels
and values into data, creating a labeled Series for easy access.
Dataframe
44
A DataFrame is a two-dimensional, size-mutable and heterogeneous tabular data structure
with labeled rows and columns, similar to a spreadsheet or SQL table. Each column in a
DataFrame is a Pandas Series, allowing you to work with multiple types of data in one table.
Syntax:
Parameters:
• data: Various forms of input data (e.g., lists, dict, ndarray, Series, another DataFrame).
• index( Optional): labels for rows.
• columns(Optional): labels for columns.
• dtype(Optional): Optional data type for all columns.
• copy(Optional): Boolean; whether to copy data or not.
Returns: A [Link] object representing a 2D labeled data structure.
45
Example 3: Selecting columns and rows in a dataFrame
46
Accessing columns and rows in a dataFrame
A DataFrame in Pandas is a 2D tabular structure where you can easily access and manipulate
data by selecting specific columns or rows. You can extract one or more columns using column
names and filter rows using labels or conditions.
Example 1: We can access one or more columns in a DataFrame using square brackets.
Explanation:
• df['Name'] returns a Series containing values from the 'Name' column.
• df[['Name', 'City']] returns a new DataFrame containing only the specified columns.
47
Explanation: [Link][df['Name'] == 'Mohe'] filters and returns only the row(s) where the
'Name' column has the value 'Mohe'.
Pandas provides a rich set of functions for efficient and flexible data manipulation. These core
features help in cleaning, transforming, and analyzing data.
Pandas functions in Python and methods that are essential for every Data Analyst and Data
Scientist to know are
read_csv()
This is one of the most crucial pandas methods in Python. read_csv() function helps read a
comma-separated values (csv) file into a Pandas DataFrame. All you need to do is mention the
path of the file you want it to read. It can also read files separated by delimiters other than
comma, like | or tab.
48
The data has been read from the data source into the Pandas DataFrame. You will have to
change the path of the file you want to read. to_csv() function works exactly opposite of
read_csv(). It helps to write data contained in a Pandas DataFrame or Series to a csv file. You
can read more about to_csv() here. read_csv() and to_csv() are one of the most used functions
in Pandas because they are used while reading data from a data source, and are very important
to know.
2. head()
head(n) is used to return the first n rows of a dataset. By default, [Link]() will return the first
5 rows of the DataFrame. If you want more/less number of rows, you can specify n as an
integer.
data_1.head(6)
tail() is similar to head(), and returns the bottom n rows of a dataset. head() and tail() help you
get a quick glance at your dataset, and check if data has been read into the DataFrame properly.
3. describe()
describe() is used to generate descriptive statistics of the data in a Pandas DataFrame or Series.
It summarizes central tendency and dispersion of the dataset. describe() helps in getting a quick
overview of the dataset.
data_1.describe()
49
describe() lists out different descriptive statistical measures for all numerical columns in our
dataset. By assigning the include attribute the value ‘all’, we can get the description to include
all columns, including those containing categorical information.
[Link]()
astype() is used to cast a Python object to a particular data type. It can be a very helpful function
in case your data is not stored in the correct format (data type). For instance, if floating point
numbers have somehow been misinterpreted by Python as strings, you can convert them back
to floating point numbers with astype(). Or if you want to convert an object datatype to
category, you can use astype().
data_1['Gender'] = data_1.[Link]('category')
You can verify the change in data type by looking at the data types of all columns in the dataset
using the dtypes attribute.
5. loc[:]
loc[:] helps to access a group of rows and columns in a dataset, a slice of the dataset, as per our
requirement. For instance, if we only want the last 2 rows and the first 3 columns of a dataset,
we can access them with the help of loc[:]. We can also access rows and columns based on
labels instead of row and column number.
50
The above code will return the “Name”, “Age”, and “State” columns for the first 5 customer
records. Keep in mind that index starts from 0 in Python, and that loc[:] is inclusive on both
values mentioned. So 0:4 will mean indices 0 to 4, both included.
loc[:] is one of the most powerful functions in Pandas, and is a must-know for all Data Analysts
and Data Scientists.
iloc[:] works in a similar manner, just that iloc[:] is not inclusive on both values. So iloc[0:4]
would return rows with index 0, 1, 2, and 3, while loc[0:4] would return rows with index 0, 1,
2, 3, and 4.
6. value_counts()
value_counts() returns a Pandas Series containing the counts of unique values. Consider a
dataset that contains customer information about 5,000 customers of a company.
value_counts() will help us in identifying the number of occurrences of each unique value in a
Series. It can be applied to columns containing data like State, Industry of employment, or age
of customers.
data_1['State'].value_counts()
The number of occurrences of each state in our dataset has been returned in the output, as
expected. value_counts() can also be used to plot bar graphs of categorical and ordinal data.
data_1['State'].value_counts(normalize=True).plot(kind='bar', title='State')
51
7. drop_duplicates()
drop_duplicates() returns a Pandas DataFrame with duplicate rows removed. Even among
duplicates, there is an option to keep the first occurrence (record) of the duplicate or the last.
You can also specify the inplace and ignore_index attribute.
data_1.drop_duplicates(inplace=True)
inplace=True makes sure the changes are applied to the original dataset. You can verify the
changes by looking at the shape of the original dataset, and the modified dataset (after dropping
duplicates). You will notice the number of rows have reduced from 9 to 8 (because 1 duplicate
has been dropped).
8. groupby()
groupby() is used to group a Pandas DataFrame by 1 or more columns, and perform some
mathematical operation on it. groupby() can be used to summarize data in a simple manner.
data_1.groupby(by='State').[Link]()
The above code will group the dataset by “State” column, and will return the mean age across
states.
9. merge()
merge() is used to merge 2 Pandas DataFrame objects or a DataFrame and a Series object on a
common column (field). If you are familiar with the concept of JOIN in SQL, merge function
similar to that. It returns the merged DataFrame.
To know more about attributes like on (including left_on and right_on), how, and suffixes,
10. sort_values()
sort_values() is used to sort column in a Pandas DataFrame (or a Pandas Series) by values in
ascending or descending order. By specifying the inplace attribute as True, you can make a
change directly in the original DataFrame.
52
data_1.sort_values(by='Name', inplace=True)
you can see that the ordering of records has changed now. Records are now listed in
alphabetical order of Names. sort_values() has many other attributes which can be specified.
1. describe()
• Provides summary statistics (count, mean, std, min, quartiles, max) for numeric
columns.
[Link]()
df['Gender'].value_counts()
[Link]()
[Link]()
Pandas makes it easy to load, read, and write various data formats such as CSV, Excel, SQL,
JSON, and more.
54
df = pd.read_csv('[Link]') # Reads a CSV file into a DataFrame
Common options:
• sep=',': Specify delimiter
• header=0: Row to use as column names
• names=[...]: Provide custom column names
• index_col=0: Set column as index
Options:
• sheet_name='Sheet1'
• usecols='A:C'
3. Loading from a Dictionary or List
df = [Link](data)
import sqlite3
conn = [Link]('[Link]')
55
3.6 STORAGE AND FILE FORMATS
Pandas supports a wide range of file formats and storage options for reading and writing
structured data efficiently. These include common formats like CSV and Excel, as well as
optimized formats like Parquet and HDF5 for performance and scalability.
Read CSV:
import pandas as pd
df = pd.read_csv('[Link]')
Write CSV:
df.to_csv('[Link]', index=False)
Read Excel:
df = pd.read_excel('[Link]', sheet_name='Sheet1')
Write Excel:
df.to_excel('[Link]', index=False)
56
Read JSON:
df = pd.read_json('[Link]')
Write JSON:
df.to_json('[Link]')
Good for nested structures; supports different orientations like 'records', 'split'.
4. HTML
df_list = pd.read_html('[Link]
Write HTML:
df.to_html('[Link]')
5. SQL Databases
Write to SQL:
Pandas supports reading from and writing to various file formats for data input and output.
This makes it easy to load data from different sources and save processed data efficiently.
Read CSV:
df = pd.read_csv('[Link]')
Write CSV:
df.to_csv('[Link]', index=False)
Read Excel:
df = pd.read_excel('[Link]', sheet_name='Sheet1')
Write Excel:
57
df.to_excel('[Link]', index=False)
Read JSON:
df = pd.read_json('[Link]')
Write JSON:
df.to_json('[Link]')
Write to HDF5:
Read HDF5:
df = pd.read_hdf('data.h5', key='df')
5. SQL Databases
import sqlite3
conn = [Link]('[Link]')
Write to SQL:
In this article, we will discuss how to read text files with pandas in Python. In Python, the
Pandas module allows us to load DataFrames from external files and work on them. The dataset
can be in different types of files.
Below are the methods by which we can read text files with Pandas:
• Using read_csv()
• Using read_table()
58
• Using read_fwf()
We will read the text file with pandas using the read_csv() function. Along with the text file,
we also pass separator as a single space (‘ ’) for the space character because, for text files, the
space character will separate each field. There are three parameters we can pass to the
read_csv() function.
Syntax:
Parameters:
• [Link]: As the name suggests it is the name of the text file from which we want to
read data.
• sep: It is a separator field. In the text file, we use the space character(' ') as the
separator.
• header: This is an optional field. By default, it will take the first line of the text file as
a header. If we use header=None then it will create the header.
• names: We can assign column names while importing the text file by using the names
argument.
Example 1
In this example, we are using read_csv() function to read the csv file.
59
Read Text Files with Pandas Using read_table()
We can read data from a text file using read_table() in pandas. This function reads a general
delimited file to a DataFrame object. This function is essentially the same as the read_csv()
function but with the delimiter = '\t', instead of a comma by default. We will read data with the
read_table function making separator equal to a single space(' ').
Parameters:
60
• [Link]: As the name suggests it is the name of the text file from which we want to
read data.
The fwf in the read_fwf() function stands for fixed-width lines. We can use this function to
load DataFrames from files. This function also supports text files. We will read data from the
text files using the read_fwf() function with pandas. It also supports optionally iterating or
breaking the file into chunks. Since the columns in the text file were separated with a fixed
width, this read_fwf() read the contents effectively into separate columns.
Syntax: data=pandas.read_fwf('[Link]')
Parameters:
• [Link]: As the name suggests it is the name of the text file from which we want to
read data.
61
Writing a File Using Pandas
data = [Link]({
'id': [ 1, 2, 3, 4, 5, 6, 7],
})
Data
62
Save the DataFrame we created above as a CSV file using pandas .to_csv() function, as
shown:
data.to_csv('[Link]')
We can also save the DataFrame as an Excel file using pandas .to_excel() function, as shown:
data.to_excel('[Link]')
Save the DataFrame we created above as a Text file using the same function that we use for
CSV files:
data.to_csv('[Link]')
There are various other file formats that you can write your data to. For example:
• .to_json()
• .to_html()
• .to_sql()
Take note that this isn’t an exhaustive list. There are more formats you can write to, but they
are out of the scope of this article.
Web scraping refers to the process of extracting data from websites using automated tools and
scripts. Web scraping can be used for a variety of purposes, such as market research, competitor
analysis, and data analysis.
Pandas is a popular data analysis library in Python that provides powerful tools for working
with structured data. In this article, we will explore how to use Pandas for web scraping and
how it can make the process easier and more efficient.
One of the key features of Pandas for web scraping is the read_html() function. This function
allows you to read HTML tables from web pages and convert them into Pandas DataFrames.
The read_html() function takes a URL as input and returns a list of all HTML tables found on
the page.
Here's an example of how to use read_html() to scrape a table from a web page:
63
In this example, we first import the Pandas library and specify the URL of the web page we
want to scrape. We then call the read_html() function with the URL as input, which returns a
list of all tables found on the page. We extract the first table from the list by indexing it with
[0].
Once you have scraped the data from a web page into a Pandas DataFrame, you can use the
full power of Pandas to clean, manipulate, and analyze the data.
Note that the read_html() function may not work for all web pages, especially those with
complex or dynamic HTML structures.
Web scraping with Pandas can be a powerful tool for extracting and analyzing data from web
pages. The read_html() function provides an easy way to scrape HTML tables, and Pandas
provides a wide range of tools for cleaning, manipulating, and analyzing the data. However,
it's important to be mindful of the legal and ethical implications of web scraping, as some
websites may prohibit or restrict scraping activities.
When working with binary files in Python, there are specific modes we can use to open them:
• 'rb': Read binary - Opens the file for reading in binary mode.
• 'wb': Write binary - Opens the file for writing in binary mode.
• 'ab': Append binary - Opens the file for appending in binary mode.
To read a binary file, you need to use Python’s built-in open() function, but with the mode 'rb',
which stands for read binary. The 'rb' mode tells Python that you intend to read the file in
binary format, and it will not try to decode the data into a string (as it would with text files).
After opening the binary file, you can use different methods to read its content.
Using read()
The open() function is used to open files in Python. When dealing with binary files, we need
to specify the mode as 'rb' (read binary) and then use read() to read the binary file.
Explanation: This code opens a binary file ([Link]) in read binary mode ('rb'). It reads
the entire content of the file into the variable bin as bytes using the read() method. After
reading the content, it prints the binary data. Finally, it closes the file using [Link]() to release
system resources.
Using readlines()
By using readlines() method we can read all lines in a file. However, in binary mode, it returns
a list of lines, each ending with a newline byte (b'\n').
65
Explanation:
Explanation:
• The file [Link] is opened in read-binary mode ('rb').
• The code reads the file in chunks of 1024 bytes using [Link](size).
• The while True loop continues until the file is fully read, breaking when no more data
is available ([Link](size) returns an empty chunk). Each chunk is printed to the console.
Python provides a module named pickle which help us to read and write binary file in python.
Remember : Before writing to binary file the structure (list or dictionary) needs to be converted
in binary format. This process of conversion is called Pickling. Reverse process Unpickling
happen during reading binary file which converts the binary format back to readable form.
Q1. Write a function bwrite() to write list of five numbers in a binary file?
66
Line wise explanation of the above code :
1. Line one is just to define our function.
2. In line 2 we are importing a module pickle which help to read and write data to binary file.
3. In line number
3, we are opening a file named “[Link]” in writing mode and ‘f’ is our file object/handle.
4. Line number 4, we are declaring a list which needs to be write in a file.
5. This line is doing the main role of writing in a file. dump function of pickle module is used
to write list in binary file.
6. This line is simply closing the file.
7. Last line is to calling function bwrite()
Python API is used to retrieve data from various sources. Also, we will cover all concepts
related to Python API from basic to advanced. Various websites provide weather data, Twitter
provides data for research purposes, and stock market websites provide data for share prices.
67
API stands for "Application Programming Interface." In simple terms, it's a set of rules and
protocols that allow how different software applications can communicate and interact with
each other. APIs define the methods and data formats that applications can use to request and
exchange information. To retrieve data from a web server, a client application initiates a
request, and the server responds with the requested data.
APIs act as bridges that enable the smooth exchange of data and functionality, enhancing
interoperability across various applications.
In order to work with API some tools are required such as requests so we need to first install
them in our system.
Command to install 'requests':
Once we have installed it, we need to import it in our code to use it.
Command to import 'requests':
68
Let us understand the working of API with examples. First let us take a simple example.
Example 1: Fetching Live Stock Price Using Alpha Vantage API
This example retrieves the latest opening price for IBM stock at a 5-minute interval. Here we
make use of 'requests' to make a call and it is checked with the help of status code that whether
our request was successful or [Link] the response is converted to python dictionary and the
respected data is stored .
Explanation:
• Sends a GET request to Alpha Vantage API.
• Checks if the request was successful (status_code == 200).
• Parses JSON response to extract latest opening stock price.
• Prints the price or error message.
69
3.11 INTERACTING WITH DATABASES
Performing various operations on data saved in SQL might lead to performing very complex
queries that are not easy to write. So to make this task easier it is often useful to do the job
using pandas which are specially built for data preprocessing and is more simple and user-
friendly than SQL. There might be cases when sometimes the data is stored in SQL and we
want to fetch that data from SQL in python and then perform operations using pandas. So let's
see how we can interact with SQL databases using pandas. This is the database we are going
to work with diabetes_data.
Basic operation
Slicing of rows We can perform slicing operations to get the desired number of rows from
within a given range. With the help of slicing, we can perform various operations only on the
specific subset of the data
70
Selecting specific columns To select a particular column or to select number of columns from
the dataframe for further processing of data.
Summarize the data In order to get insights from data, we must have a statistical summary of
data. To display a statistical summary of the data such as mean, median, mode, std etc. We
perform the following operation
Sort data with respect to a column For sorting the dataframe with respect to a given column
values
71
Display mean of each column To Display the mean of every column of the dataframe.
This includes handling missing data, correcting data types, removing duplicates, etc.
Missing data can be detected and handled using isnull(), dropna(), fillna(), etc.
72
DATA TRANSFORMATION
Includes operations like renaming columns, changing data types, and applying functions to
columns.
73
Unit - IV
Data Visualization Tools in Python- Introduction to Matplotlib, Basic plots Using matplotlib,
Specialized Visualization Tools using Matplotlib, Advanced Visualization Tools using Matplotlib-
Waffle Charts, Word Clouds.
Data visualization is the graphical representation of information and data. In Python, a wide
range of libraries and tools are available to create both basic plots and advanced interactive
visualizations. These tools help explore, analyze, and communicate data insights effectively.
74
4.1 INTRODUCTION TO MATPLOTLIB
Matplotlib is a widely-used Python library used for creating static, animated and interactive
data visualizations. It is built on the top of NumPy and it can easily handles large datasets for
creating various types of plots such as line charts, bar charts, scatter plots, etc. These
visualizations help us to understand data better by presenting it clearly through graphs and
charts. In this article, we will see how to create different types of plots and customize them in
matplotlib.
75
Installing Matplotlib for Data Visualization
If we are working on a Jupyter Notebook, we can install Matplotlib directly inside a notebook
cell by running:
Matplotlib provides a module called pyplot which offers a MATLAB-like interface for
creating plots and charts. It simplifies the process of generating various types of visualizations
by providing a collection of functions that handle common plotting tasks. Let’s explore some
examples with simple code to understand how to use it effectively.
76
4.2 BASIC PLOTS USING MATPLOTLIB
1. Line Chart
Line chart is one of the basic plots and can be created using the plot() function. It is used to
represent a relationship between two data X and Y on a different axis.
Syntax:
2. Bar Chart
A bar chart is a graph that represents the category of data with rectangular bars with lengths
and heights which is proportional to the values which they represent. The bar plot can be
plotted horizontally or vertically. It describes the comparisons between different categories
and can be created using the bar() method.
In the below example we will using Pandas library for its implementation on tips dataset. It is
the record of the tip given by the customers in a restaurant for two and a half months in the
early 1990s and it contains 6 columns.
Syntax:
77
[Link](x, height, width=0.8, bottom=None, color=None, edgecolor=None,
linewidth=None)
3. Histogram
A histogram is used to represent data provided in a form of some groups. It is a type of bar
plot where the X-axis represents the bin ranges while the Y-axis gives information about
frequency. The hist() function is used to find and create histogram of x.
Syntax:
78
4. Scatter Plot
Scatter plots are used to observe relationships between variables. The scatter() method in the
matplotlib library is used to draw a scatter plot.
Syntax:
79
5. Pie Chart
Pie chart is a circular chart used to display only one series of data. The area of slices of the
pie represents the percentage of the parts of the data. The slices of pie are called wedges. It
can be created using the pie() method.
Syntax:
80
6. Box Plot
A Box Plot is also known as a Whisker Plot which is a standardized way of displaying the
distribution of data based on a five-number summary: minimum, first quartile (Q1), median
(Q2), third quartile (Q3) and maximum. It can also show outliers.
Syntax:
81
The box shows the interquartile range (IQR) the line inside the box shows the median and the
"whiskers" extend to the minimum and maximum values within 1.5 * IQR from the first and
third quartiles. Any points outside this range are considered outliers and are plotted as
individual points.
7. Heatmap
A Heatmap represents data in a matrix form where individual values are represented as colors.
They are useful for visualizing the magnitude of multiple features in a two-dimensional surface
and identifying patterns, correlations and concentrations.
Syntax:
82
The color bar on the side provides a scale to interpret the colors, darker colors representing
lower values and lighter colors representing higher values. This type of plot is used in fields
like data analysis, bioinformatics and finance to visualize data correlations and distributions
across a matrix.
They allow you to create visualizations such as heatmaps, radar charts, 3D plots, polar plots,
and more using Matplotlib’s flexible plotting architecture.
1. Customization
You can control every element of a plot—colors, axes, annotations, markers, and more.
2. High-Dimensional Data Support
Create 3D plots, surface plots, and multivariate charts like radar plots.
83
3. Domain-Specific Visuals
Useful in fields like finance, biology, engineering (e.g., polar plots for angles, heatmaps
for genomics).
4. Integration
Works seamlessly with NumPy, Pandas, and other Python libraries.
[Link]
2. Word Count
84
3. Stacked Area Chart
4. 3D Surface Plot
85
5. Quiver Plot
Quiver plots are used to display vector fields. Each arrow shows both direction and magnitude
of the vector at a point. They are especially useful in physics, fluid dynamics, and wind flow
analysis.
A waffle chart is a grid-based visualization that shows proportional data. Each square in the
grid represents a percentage or count of the total.
Library:
86
Use Case:
Comparing categories visually like pie charts, but in a more structured format.
2. Word Cloud
A word cloud is a visual representation of text data where the size of each word indicates its
frequency or importance.
Library:
Wordcloud
87
Use Case:
88
Unit - V
Introduction: Data Analysis, Excel Data analysis. Working with range names. Tables. Cleaning Data.
Conditional formatting, Sorting, Advanced Filtering, Lookup functions, Pivot tables, Data
Visualization, Data Validation. Understanding Analysis tool pack: Anova, correlation, covariance,
moving average, descriptive statistics, exponential smoothing, fourier Analysis, Random number
generation, sampling, ttest, f-test, and regression.
Data analysis is the process of cleaning, changing, and processing raw data and extracting
actionable, relevant information that helps businesses make informed decisions.
The procedure helps reduce the risks inherent in decision-making by providing useful insights
and statistics, often presented in charts, images, tables, and graphs.
Data Analysis is the process of systematically applying statistical and/or logical techniques to
describe and illustrate, condense and recap, and evaluate data.
An essential component of ensuring data integrity is the accurate and appropriate analysis of
research findings. Data analysis plays a crucial role in processing big data into useful
information.
89
202
90
Considerations/issues in data analysis
There are a number of issues that researchers should be cognizant of with respect to data
analysis.
These include:
• Having the necessary skills to analyze
• Concurrently selecting data collection methods and appropriate analysis
• Drawing unbiased inference
• Inappropriate subgroup analysis
• Following acceptable norms for disciplines
• Determining statistical significance
• Lack of clearly defined and objective outcome measurements
Excel is one of the most powerful tools for data analysis, allowing you to process, manipulate,
and visualize large datasets efficiently. Whether you're analyzing sales figures, financial
reports, or any other type of data, knowing how to perform data analysis in Excel can help
you make informed decisions quickly. In this guide, we will walk you through the essential
steps to analyze data in Excel, including using built-in tools like pivot tables, charts, and
formulas to extract meaningful insights. By the end of this article, you’ll have a solid
understanding of how to use Excel for data analysis and improve your decision-making
process.
Data cleaning becomes an intuitive process with Excel's capabilities, allowing users to identify
and rectify issues like missing values and duplicates. PivotTables, a hallmark feature, empower
users to swiftly summarize and explore large datasets, providing dynamic insights through
customizable cross-tabulations, making Data Analysis Excel an essential skill for
professionals.
Before getting into analysis, it’s essential to clean and organize your dataset to ensure accuracy.
How to Clean Data in Excel
1. Remove Duplicates: Use Data > Remove Duplicates to eliminate redundancy.
2. Use TRIM and CLEAN Functions:
• TRIM removes unnecessary spaces.
• CLEAN removes non-printable characters.
3. Sort and Structure Data: Convert your dataset into an Excel Table (Insert > Table) for
better organization.
91
Basic Methods of Data Analysis in Excel
Excel offers several methods to analyze data effectively. Here are some key techniques:
We can use the name for the cell Ranges instead of the cell reference (such as A1 or A1:A10).
We can create a named range for a range of cells and use then use that name directly in the
Excel formulas. When we have huge data sets, Excel-named ranges make it easy to refer (by
directly using a name to that data set).
• Give a new Name(PriceTotal in our example) & click Ok. (You can see the range in
the bottom refers to section, here absolute referencing is used, $ before the row number/
column letter locks the row/column).
93
• Now, the next thing is to see that how to use this named range in any of the Excel
formulas. For example, if you want to get the sum of all numbers in the above name
range then, can say simply write: =SUM(PriceTotal).
5.4 TABLES
4. In the Format as Table dialog box, select the checkbox next to My table as headers if
you want the first row of the range to be the header row, and then click OK.
94
5.5 EXCEL DATA CLEANING TECHNIQUES
In today's data-driven world, having clean and reliable data is crucial for making informed
business decisions. In this article, you will learn different techniques to clean data in Excel that
will transform your excel spreadsheets from chaotic to organized. Whether you're a beginner
or an experienced user, mastering these techniques can significantly enhance your data analysis
skills.
We'll explore powerful tools such as Power Query to automate data cleaning tasks, conditional
formatting to highlight inconsistencies, and other essential data cleaning tools that can
streamline your workflow. Say goodbye to messy data and hello to accurate insights as we dive
into the world of Excel data cleaning!
Excel provides some indispensable Data-Cleaning techniques to do data cleaning easily. The
most widely used techniques are :
1. Remove Duplicates
Duplicate entries can sneak into your data when copying and pasting from various sources.
Excel simplifies the process of removing duplicates, saving you time and effort. Excel has
a built-in function to remove duplicates, which can save you a lot of time and effort. To do this,
follow these steps:
2. Standardize Formats
Inconsistent formatting can hinder data analysis. To standardize formats (such as currency,
dates, and times), use Excel’s formatting tools. Here’s how:
Text data often harbors errors like typos, extra spaces, and inconsistent capitalization. Excel
offers handy functions for cleaning text data:
95
• PROPER: Capitalizes the first letter of each word.
5. Data Validation
Data validation can help to prevent errors from being entered into your data in the first place.
You can use data validation to specify the type of data that can be entered into a cell, as well
as the range of valid values.
6. Conditional Formatting
Highlight errors or anomalies in your data using conditional formatting. For instance, you can:
Conditional formatting is used to change the appearance of cells in a range based on your
specified conditions.
The conditions are rules based on specified numerical values or matching text.
The browser version of Excel provides a number of built-in conditions and appearances:
96
Conditional Formatting Example
2. Click on the Conditional Formatting icon in the ribbon, from the Home menu
97
The color on the top of the icon will apply to the highest values.
Now, the Speed value cells will have a colored background highlighting:
Dark green is used for the highest values, and dark red for the lowest values.
98
Charizard has the highest Speed value (100) and Squirtle has the lowest Speed value (43).
All the cells in the range gradually change color from green, yellow, orange, then red.
EXCEL SORTING
Ranges can be sorted using the Sort Ascending and Sort Descending commands.
The sort commands work for text too, using A-Z order.
The commands are found in the Ribbon under the Sort & Filter menu ( )
Sort the Pokemons in the range A2:A21 by their Name, ascending from smallest to largest (A-
Z).
1. Select A2:A21
Note: A1 is not included as it is the header for the column. This is the row that is dedicated to
the filter. Including it will blend it with the rest.
99
ADVANCED FILTER IN EXCEL
This example teaches you how to apply an advanced filter in Excel to only display records that
meet complex criteria.
When you use the Advanced Filter, you need to enter the criteria on the worksheet. Create
a Criteria range (blue borders in the image below for illustration only) above your data set. Use
the same column headers. Be sure there's at least one blank row between your Criteria range
and data set.
And Criteria
To display the sales in the USA and in Qtr 4, execute the following steps.
100
2. Click any single cell inside the data set.
3. On the Data tab, in the Sort & Filter group, click Advanced.
4. Click in the Criteria range box and select the range A1:D2 (blue).
5. Click OK.
101
Notice the options to copy your filtered data set to another location and display unique records
only (if your data set contains duplicates).
No rocket science so far. We can achieve the same result with the normal filter. We need the
Advanced Filter for Or criteria.
LOOKUP FUNCTIONS
Excel’s LOOKUP functions look for and get data from tables according to particular criteria.
They are crucial instruments for data analysis. Furthermore, they make it possible for users to
locate and get data from huge databases quickly.
102
1. LOOKUP Function
Excel’s LOOKUP function is useful for finding a value inside a range or array. There are two
types of it: array and vector.
Syntax:
Example: The LOOKUP function may locate the name linked to a certain ID. If you have a
list of employee IDs in column A and their corresponding names in column B, the result will
be the ID that you are looking for.
103
2. VLOOKUP Function
Excel’s most frequently used function is the VLOOKUP function. It retrieves a value from
another column in the same row after looking for a value in the first column of a range.
Syntax
Example: To find the City of a customer in the Sales table using the CustomerID:
=VLOOKUP(A15,$A$1:$C$11,3,0)
104
3. HLOOKUP Function
The HLOOKUP function is another LOOKUP function in Excel. After searching the top row
of a range for a given value, it retrieves a value from a different row in the same column.
Example: Assuming the Customers table is transposed horizontally (customer data in rows):
4. XLOOKUP Function
XLOOKUP was created to replace VLOOKUP and HLOOKUP. It has improved features, and
it is more powerful and versatile.
105
Example: To find the city of an customer’s Name using their ID from a table where IDs are in
column A and Name in column B:
106