Data Handling using Pandas - II
CBSE · Class 12 · Informatics Practices
NCERT Solutions for Data Handling using Pandas - II — CBSE Class 12 Informatics Practices.
Interactive on Super Tutor
Studying Data Handling using Pandas - II? Get the full interactive chapter.
Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for ncert solutions and more.
1,000+ Class 12 students started this chapter today
14 worked solutions below. Unlock all 28 free in Super Tutor
Exercise
1Write the statement to install the python connector to connect MySQL i.e. pymysql.Show solution
```bash
pip install pymysql
```
Not sure why a step works? check your working in Super Tutor
2Explain the difference between pivot() and pivot_table() function?Show solution
pivot_table() works like pivot(), but it can handle duplicate entries by applying an aggregate function such as mean, sum, max, or min. The default aggregate function is mean.
So, the main difference is:
- pivot() does not work with duplicate values for the chosen index/columns.
- pivot_table() can reshape data even when duplicates are present, by aggregating them.
Not sure why a step works? check your working in Super Tutor
3What is sqlalchemy?Show solution
Not sure why a step works? check your working in Super Tutor
4Can you sort a DataFrame with respect to multiple columns?Show solution
For example, if marks in Science are the same, then sorting can be done using Hindi as the next column:
```python
dfUT3 = df[df.UT == 3]
print(dfUT3.sort_values(by=['Science', 'Hindi']))
```
Here, the data is first sorted by Science and then by Hindi.
Not sure why a step works? check your working in Super Tutor
5What are missing values? What are the strategies to handle them?Show solution
The two main strategies to handle missing values are:
1. Drop the object (row) having missing values.
2. Fill/estimate the missing value using an appropriate value, such as 0, 1, previous value, next value, average, minimum, or maximum.
Not sure why a step works? check your working in Super Tutor
6Define the following terms: Median, Standard Deviation and variance.Show solution
- Standard Deviation: the measure of how much the values vary from the mean; it is the square root of variance.
- Variance: the average of squared differences from the mean.
Not sure why a step works? check your working in Super Tutor
7What do you understand by the term MODE? Name the function which is used to calculate it.Show solution
Not sure why a step works? check your working in Super Tutor
8Write the purpose of Data aggregation.Show solution
Not sure why a step works? check your working in Super Tutor
9Explain the concept of GROUP BY with help on an example.Show solution
Example: if we group the marks DataFrame by Name, we can find the first entry, size, or sum for each student.
```python
g1 = df.groupby('Name')
print(g1.first())
print(g1.size())
```
This creates separate groups for Raman, Zuhaire, Ashravy and Mishti, and then operations can be performed group-wise.
Not sure why a step works? check your working in Super Tutor
10Write the steps required to read data from a MySQL database to a DataFrame.Show solution
1. Install and import the required libraries, such as `pymysql` and `sqlalchemy`.
2. Create a connection engine using `create_engine()`.
3. Use one of the Pandas functions to read the table/query, such as:
- `pd.read_sql_query(query, engine)`
- `pd.read_sql_table(table_name, engine)`
- `pd.read_sql(sql, engine)`
4. Store the result in a DataFrame.
Example:
```python
engine = create_engine('mysql+pymysql://root:password@localhost:3306/database_name')
df = pd.read_sql_query('SELECT * FROM INVENTORY', engine)
```
Not sure why a step works? check your working in Super Tutor
11Explain the importance of reshaping of data with an example.Show solution
Example: the sales data of stores can be reshaped so that Store becomes the index and Year becomes the columns. Then sales values are easier to compare across years.
This is important because reshaping can make data more readable, organized, and easier to analyze.
Not sure why a step works? check your working in Super Tutor
12Why estimation is an important concept in data analysis?Show solution
Not sure why a step works? check your working in Super Tutor
13Assuming the given table: Product. Write the python code for the following:Show solution
For example:
```python
import pandas as pd
data = {
'Item': ['TV', 'TV', 'TV', 'AC'],
'Company': ['LG', 'VIDEOCON', 'LG', 'SONY'],
'Rupees': [12000, 10000, 15000, 14000],
'USD': [700, 650, 800, 750]
}
df = pd.DataFrame(data)
```
This creates the DataFrame for the given table.
Not sure why a step works? check your working in Super Tutor
13(a)To create the data frame for the above table.Show solution
```python
import pandas as pd
data = {
'Item': ['TV', 'TV', 'TV', 'AC'],
'Company': ['LG', 'VIDEOCON', 'LG', 'SONY'],
'Rupees': [12000, 10000, 15000, 14000],
'USD': [700, 650, 800, 750]
}
df = pd.DataFrame(data)
print(df)
```
Not sure why a step works? check your working in Super Tutor
14 more solved questions in Data Handling using Pandas - II
Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.
Stuck on a step?
Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.
Ask a Doubt FreeFrequently Asked Questions
What are the important topics in Data Handling using Pandas - II for CBSE Class 12 Informatics Practices?
How to score full marks in Data Handling using Pandas - II — CBSE Class 12 Informatics Practices?
Where can I get free NCERT Solutions for Data Handling using Pandas - II Class 12 Informatics Practices?
Sources & Official References
- NCERT Official — ncert.nic.in
- CBSE Academic — cbseacademic.nic.in
- CBSE Official — cbse.gov.in
- National Education Policy 2020 — education.gov.in
Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.
More resources for Data Handling using Pandas - II
Practice Quiz
Test yourself with a quick quiz
Important Questions
Practice with board exam-style questions
Revision Notes
Key points for last-minute revision
Formula Sheet
All formulas in one place
Chapter Summary
Understand the chapter at a glance
Concept Maps
See how topics connect visually
Study Plan
Step-by-step plan to ace this chapter
Flashcards
Quick-fire cards for active recall
Syllabus
What topics to cover
For serious students
Get the full Data Handling using Pandas - II chapter — for free.
Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 12 Informatics Practices.