Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
139 views

Python Pandas For Class XI Tutorial 1

Here are the solutions to the problems in the Python Pandas tutorial: 1. Python Pandas is a software library written for the Python programming language for data manipulation and analysis. It is used for working with structured and time series data in Python. 2. Python Pandas is used for data cleaning and transformation, aggregation and summary statistics, visualization, merging, joining and reshaping of data. It allows import/export of data to different formats like CSV, Excel, SQL databases etc. 3. a) data.head() b) data.tail() c) data.iloc[3:6] d) data.iloc[0:4] e) data.iloc[2:7] f

Uploaded by

Abdul Malik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

Python Pandas For Class XI Tutorial 1

Here are the solutions to the problems in the Python Pandas tutorial: 1. Python Pandas is a software library written for the Python programming language for data manipulation and analysis. It is used for working with structured and time series data in Python. 2. Python Pandas is used for data cleaning and transformation, aggregation and summary statistics, visualization, merging, joining and reshaping of data. It allows import/export of data to different formats like CSV, Excel, SQL databases etc. 3. a) data.head() b) data.tail() c) data.iloc[3:6] d) data.iloc[0:4] e) data.iloc[2:7] f

Uploaded by

Abdul Malik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Syllabus of Python Pandas

4.2 Unit 2: Data Handling (DH-1) (30 Theory + 20 Practical)


4.2.1. Introduction to Python Pandas
✓ Introduction to data structures in Pandas: Series, and Data Frame
✓ Operations on a Series: head, tail, vector operations
✓ Data Frame operations: create, display, iteration, select column, add column, delete column
✓ Binary operations in a Data Frame: add, sub, mul, div, radd, rsub
✓ Matching and broadcasting operations
✓ Missing data and filling values.
✓ Comparisons, Boolean reductions, comparing Series, and combining Data Frames.

4.2.2. Transfer data between CSV files/SQL databases, and Data Frame objects.

Python Pandas Tutorial 1


Introduction to Python Pandas
Pandas is a Python module. The Pandas module is a high performance, highly efficient, and high-level
data analysis library. It is like operating a spreadsheet like Excel
Data Structures in Pandas
Pandas deals with three data structures
➢ Series
➢ DataFrame
➢ Panel

Series 1 D array
23 14 56 28 43 39 19 40 65

➢ The size is immutable.


➢ Homogeneous data
➢ Values of data mutable.

DataFrame Two-dimensional data


Name Age Gender Rating
Ashish 23 Male 3.6
Janvi 25 Female 4.7
Jatin 24 Male 3.9
Kritika 26 Female 2.8
Data is represented in rows and columns. Each column represents an attribute.
Each row represents a person.
➢ Heterogeneous data type. Here data type of four columns are – String,
Integer, String, Float
➢ Size Mutable
➢ Data Mutable
Creation of Series: A series can be created using
➢ List
➢ Dictionary
➢ Scalar value or constant
Creation of Series using List
Example 1

To display the values – data.values


To display the index – data.index
Example 2

By default, index is assigned from 0 to len(data) – 1.


To display a particular index value
To display first five values – data.head()
To display bottom five values – data.tail()
To change the index: You can give your own index value.
Example 3

To display particular number of records


Head() It displays top five values.
Tail() It displays the bottom five values.

To display the particular index.

By default, index is assigned from 0 to len(data) – 1.


To dislplay the data using index – data.iloc[2 : 5]
To display the data location wise – data.loc[‘c’: ‘e’]
Create a Series from Dictionary
A dictionary can be passed as input and if no index is specified, then the dictionary keys are taken in
sorted order to construct index. If index is passed, the values in data corresponding to the labels in the
index will be pulled out.
Example 1

Dictionary keys are used to construct index.


Example 2

Index order is persisted and the missing element is filled with NaN (Not a number).
Create a Series from Scalar
If data is a scalar value, an index must be provided. The value will be repeated to match the length of
index.
Example 1

Retrieve values using condition


You can perform arithmetic operations as Addition, Subtraction, Division, Multiplication and
exponential.
Worksheet I
Introduction to data structures in Pandas: Series
Operations on a Series: head, tail, vector operations
1. What is Python Pandas?

2. Why it is used?

3. Write a Python program to create and display a series of even numbers 2, 4, 6, 8, 10, 12, 14, 16, 18,
20 using Pandas module. Also do the following:
a. Display the first 5 index values.
b. Display the last 5 index values.
c. Display index 4,6,and 8.
d. Display the first four index values.
e. Display the index 3 to 7.
f. Display the index 6 to end.
g. Display using data.iloc[2:7]

4. Write a Python program to create and display a series of even numbers 2, 4, 6, 8, 10, 12, 14, 16, 18,
20 with index value a, b, c, d, e, f, g, h, I, j using Pandas module.
a. Display the first 5 index values.
b. Display the last 5 index values.
c. Display index 4,6,and 8.
d. Display the first four index values.
e. Display the index 3 to 7.
f. Display the index 6 to end.
g. Using data.loc[‘d’:’h’]
5. Write a Python program to create a series of list [ 34, 29, 65, 57, 42] and do the following:
a. Raise to power 2 of values
b. Add 1000
c.. Subtract 500
d. Multiply by 2
e. Divide by 20
f. Display all the values greater than 50
6. Write a Python program to create and display a series of dictionary consists of Name : Marks of your
ten friends and do the following:
a. Display the first five values.
b. Display the last three values.
c. Give the index with two extra value and then display.
7. Write a Python program to create a series of scalar value 500 of index ‘A’..’F’.

You might also like