0% found this document useful (0 votes)
12 views

data visualization lab manual (1)

The document is a data visualization manual that covers loading data, distinguishing between dependent and independent variables, and various visualization techniques using libraries like Pandas, Seaborn, and Matplotlib. It includes code examples for creating histograms, bar charts, line graphs, scatter plots, and heatmaps, as well as working with regular expressions and network data visualization. Additionally, it outlines different frameworks available for data visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

data visualization lab manual (1)

The document is a data visualization manual that covers loading data, distinguishing between dependent and independent variables, and various visualization techniques using libraries like Pandas, Seaborn, and Matplotlib. It includes code examples for creating histograms, bar charts, line graphs, scatter plots, and heatmaps, as well as working with regular expressions and network data visualization. Additionally, it outlines different frameworks available for data visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Data visualization manual Bhavya

1) Loading and Distinguishing Dependent and Independent Parameters


Code:-
import pandas as pd

# Corrected file path (with raw string or properly escaped backslashes)


data = pd.read_csv(r"C:\Users\ADMIN\Desktop\data sets\IRIS.csv")

# Selecting independent and dependent variables


X = data[['sepal_length', 'sepal_width']]
Y = data['species']

# Print the first few rows of the independent and dependent variables
print('Independent Variables:', X.head())
print('Dependent Variable:', Y.head())

out put

Independent Variables: sepal_length sepal_width


0 5.1 3.5
1 4.9 3.0
2 4.7 3.2
3 4.6 3.1
4 5.0 3.6
Dependent Variable: 0 Iris-setosa
1 Iris-setosa
2 Iris-setosa
3 Iris-setosa
4 Iris-setosa
Name: species, dtype: object
2) Exploring Data Visualization
Tools Code:-
import seaborn as sns
import matplotlib.pyplot as plt

# Load the 'tips' dataset


tips = sns.load_dataset('tips')

# Create a histogram of the 'total_bill' column


sns.histplot(tips['total_bill'], bins=20)

# Show the plot


plt.show()

out put
Data visualization manual Bhavya

3) Drawing Charts
Code:-
import matplotlib.pyplot as plt
categories = ['A', 'B', 'C']
values = [10, 20, 15]
plt.bar(categories, values, color=['red', 'blue', 'green'])
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Bar Chart Example')
plt.show()

out put
Data visualization manual Bhavya

4) Drawing Graphs
Code:-
x = [1, 2, 3, 4, 5]
y = [10, 12, 15, 18, 25]
plt.plot(x, y, marker='o', linestyle='-',
color='b') plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Graph Example')
plt.grid()
plt.show()

out put
Data visualization manual Bhavya

5) Data Mapping
Code:-
import seaborn as sns
import numpy as np
matrix = np.random.rand(5, 5)
sns.heatmap(matrix, annot=True, cmap='coolwarm')
plt.show()

output:-
Data visualization manual Bhavya

6) Creating Scatter Plot


Maps Code:-

import seaborn as sns


import numpy as np
matrix = np.random.rand(5, 5)
tips = sns.load_dataset('tips')
sns.scatterplot(x='total_bill', y='tip', data=tips, hue='sex')

output:-
Data visualization manual Bhavya

7) Using BNF Notations

8) Working with
REGEX Code:
import re
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
def validate_email(email):
return bool(re.match(email_pattern,
email))
print(validate_email('[email protected]'))
print(validate_email('invalid-email'))
Data visualization manual Bhavya

out put

True
False

9) Visualizing Network
Data Code:-

import networkx as nx
G = nx.Graph()
G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 1)])
nx.draw(G, with_labels=True, node_color='lightblue', edge_color='gray')
plt.show()

out put-
Data visualization manual Bhavya

10) Understanding Data Visualization Frameworks

Step 1: Understand various frameworks available for data visualization


- Matplotlib: Basic visualizations
- Seaborn: Statistical data visualization
- Plotly: Interactive charts
- NetworkX: Graph-based visualizations

You might also like