Professional Documents
Culture Documents
DH Using Pandas-1 CBQs
DH Using Pandas-1 CBQs
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.
5. What are basic steps to connect Pandas DataFrame (i.e. table) to MySQL.
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
a) srs1 + srs2
b) srs2 – srs1
c) srs1 * srs2
d) srs2 / srs1
e) srs1 + srs3
f) srs3 – srs2
g) srs3 * srs1
h) srs2 / srs3