0% found this document useful (0 votes)
3 views4 pages

Data Handling Visualization Management Solutions Color Coded

The document provides examples of data handling using pandas and numpy, including creating Series from dictionaries and ndarrays, as well as filtering elements above the 75th percentile. It also includes a visualization example using matplotlib to analyze student performance in Math and Science. Additionally, it demonstrates data management by creating and joining Students and Courses tables in SQL to display student and course details.

Uploaded by

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

Data Handling Visualization Management Solutions Color Coded

The document provides examples of data handling using pandas and numpy, including creating Series from dictionaries and ndarrays, as well as filtering elements above the 75th percentile. It also includes a visualization example using matplotlib to analyze student performance in Math and Science. Additionally, it demonstrates data management by creating and joining Students and Courses tables in SQL to display student and course details.

Uploaded by

kotasthaneananya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Data Handling, Visualization, and Management Solutions

Data Handling

1. Create a pandas Series from a dictionary of values and a ndarray

import pandas as pd

import numpy as np

# From a dictionary

data_dict = {'a': 10, 'b': 20, 'c': 30}

series_from_dict = pd.Series(data_dict)

# From a ndarray

data_array = np.array([40, 50, 60])

series_from_array = pd.Series(data_array, index=['x', 'y', 'z'])

print(series_from_dict)

print(series_from_array)

2. Given a Series, print all elements above the 75th percentile

data = pd.Series([10, 20, 30, 40, 50, 60, 70, 80, 90])

threshold = data.quantile(0.75)

above_75th = data[data > threshold]

print("75th Percentile:", threshold)

print("Elements above 75th Percentile:")


print(above_75th)

Visualization

1. Analyze school result data

import matplotlib.pyplot as plt

df_exam.set_index('Name')[['Math', 'Science']].plot(kind='bar', title="Student

Performance")

plt.ylabel('Scores')

plt.show()

Data Management

8. Joining two tables to display student and course details

-- Create the Students table

CREATE TABLE Students (

StudentID INT PRIMARY KEY,

Name VARCHAR(50),

Marks INT

);

-- Insert data into Students

INSERT INTO Students (StudentID, Name, Marks)

VALUES

(1, 'Alice', 85),

(2, 'Bob', 90),


(3, 'Charlie', 78);

-- Create the Courses table

CREATE TABLE Courses (

CourseID INT PRIMARY KEY,

StudentID INT,

CourseName VARCHAR(50),

FOREIGN KEY (StudentID) REFERENCES Students(StudentID)

);

-- Insert data into Courses

INSERT INTO Courses (CourseID, StudentID, CourseName)

VALUES

(101, 1, 'Mathematics'),

(102, 2, 'Science'),

(103, 3, 'History');

-- Use JOIN to combine data from Students and Courses

SELECT

Students.StudentID,

Students.Name,

Courses.CourseName,

Students.Marks

FROM

Students

JOIN

Courses
ON

Students.StudentID = Courses.StudentID;

You might also like