Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

DATA HANDLING USING PANDAS –1

COMPETENCY–BASED QUESTIONS
1. What advantages does dataframe offer over series datastructure? If you have similar data stored in a
multiple series and a single dataframe, which one would you prefer and why?

2. Four series objects T1, T2, T3 and T4 stores the temperature of week1, week2, week3 and week4
respectively. Create a dataframe from these four series objects where the indexes should be ‘Sun’, ‘Mon’,
‘Tues’, ‘Wed’, ‘Thurs’, ‘Fri’, ‘Sat’ and columns should be ‘Week1’, ‘Week2’, ‘Week3’, and ‘Week4’.

3. From the dataframe object created in the above question, write a code/script to calculate:
(a) average temperature per week
(b) average temperature of whole month.

4. Explain briefly the CSV format of storing files.

5. What are basic steps to connect Pandas DataFrame (i.e. table) to MySQL.

6. What is the function of connection.cursor( ) and connection.close( )?

7. Name the syntax used to fill missing values in a DataFrame.

8. Which function is used to perform the operation for the entire dataframe?
9. Create two dataframes using the following two Dictionaries. Merge the two dataframes and append the
second dataframe as a new column to the first dataframe on the basis of the manufacturing company's
name
Car_Price = {'Company': ['Toyota', 'Honda', 'BMW', 'Audi'], 'Price': [23845, 17995, 135925, 71400]}

Car_Horsepower = {'Company': ['Toyota', 'Honda', 'BMW', 'Audi'], 'Horsepower': [141, 80, 182, 160]}

Expected Output:
Company Price Horsepower
0 Toyota 23845 141
1 Honda 17995 80
2 BMW 135925 182
3 Audi 71400 160

10. Given following series srs1, srs2 and srs3

>>> srs1 >>> srs2 >>> srs3


1 11 1 21 7 31
2 12 2 22 8 32
3 13 3 23 9 33
4 14 4 24 10 34
dtype: int64 dtype: int64 dtype: int64
Give output for the following

a) srs1 + srs2
b) srs2 – srs1
c) srs1 * srs2
d) srs2 / srs1
e) srs1 + srs3
f) srs3 – srs2
g) srs3 * srs1
h) srs2 / srs3

You might also like