0% found this document useful (0 votes)
9 views3 pages

Interactive Class

Uploaded by

chandrakantha628
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)
9 views3 pages

Interactive Class

Uploaded by

chandrakantha628
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/ 3

Interactive Class

SL. Question
No.
1. Develop a Python code using the Python libraries and write the output for the following.

index = [('California', 2000), ('California', 2010), ('New York', 2000), ('New York', 2010),
('Texas', 2000), ('Texas', 2010)]
populations = [33871648, 37253956,18976457, 19378102,20851820, 25145561]

i. Create a Series of populations and index as index.


ii. Write output after executing code- pop [('California', 2010):('Texas', 2000)]
iii. Use MultiIndex.from_tuples method for multi-index and reindex the same. Display
only 2000-year data.
iv. Display only 2010 data.
v. Display values by index name.
vi. Unstack by level 0 and level 1.

2. Develop a Python code using the Pandas and write the output for the following.

i. Create the data frame which looks as below.

ii. Display health data of Bob only.


iii. Display health data of Sue’s Temp.
iv. Display Bob’s HR values.
v. Display only year 2014 values.

3. Develop a Python code using the Pandas and write the output for the following.

i. Create any 3 data frames.


ii. Using the created data frame(i) perform One-to-one joins, many-to-one joins, many-
to-many joins.
iii. Make use of options – on, left_on, right_on provided by pd.merge( ) to work on join
operations.

4. Develop a Python code for the following using ‘Planets’ dataset.


method number orbital_period mass distance year

0 Radial Velocity 1 269.300000 7.100 77.40 2006

1 Radial Velocity 1 874.774000 2.210 56.95 2008

2 Radial Velocity 1 763.000000 2.600 19.84 2011


3 Radial Velocity 1 326.030000 19.400 110.62 2007

4 Radial Velocity 1 516.220000 10.500 119.47 2009

i. Apply any five Pandas aggregation methods on the Planets dataset.


ii. List the method in Planets.
iii. Calculate the median of orbital_period of each method.
iv. Calculate mass of each method
v. Calculate the count of planets discovered on each year.
vi. Display count of Method of discovery of each of these planets.

5. Illustrate Aggregate, filter, transform, apply with an example.


6. Develop a Python code for the following using ‘'titanic'’ dataset.

i. Find survival rate by gender.


ii. Find the average survival rate of each by gender
iii. average survival rate by age.

7. Develop a Python code using Matplotlib and write the output for the following.
i. Create an array 'x' with 100 evenly spaced values from 0 to 10.
ii. Plot sin(x) and cos(x). Save as an image in PNG format.
iii. Create four simple line plots of a sine wave of different colors on each in the
same graph.
iv. Create a simple line plot, adjust using axis limit functions, and reverse the
order of the arguments.
v. Create a simple line plot of four different styles.
vi. Generate a scatter plot with random data points.
vii. Create a simple grid of subplots and use GridSpec.

8. Illustrate two different ways of Visualizing Errors.


9. Differentiate between Seaborn and Matplotlib with an example.
10. Develop a Python code using Seaborn and write the output for the following.
i. Create a dataframe contains ‘x’ and ‘y’ columns having random numbers.
ii. Draw a histogram for the above dataframe.
iii. Draw a kdeplot for the above dataframe.
iv. Combine the Histograms and KDE using distplot.
v. Draw a joint plot for the above dataframe.

11. Develop a Python code using Seaborn and write the output for the following.
iris = sns.load_dataset("iris")
iris.head()

sepal_length sepal_width petal_length petal_width species


0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
i. Load ‘iris’ dataset from seaborn.
ii. Visualizing the multidimensional relationships among the samples using pair
plot.

12. Develop a Python code using Seaborn and write the output for the following.
tips = sns.load_dataset('tips')
tips.head()

total_bill tip sex smoker day time size


0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun lunch 4

i. Visualize the percentage of tips received by each gender during lunch and
dinner using faceted histogram: FacetGrid and factorplot.
ii. Illustrate the use of jointplot.

13. Develop a Python code using Seaborn and write the output for the following.
planets = sns.load_dataset('planets')
planets.head()
method number orbital_period mass distance year

0 Radial Velocity 1 269.300000 7.100 77.40 2006

1 Radial Velocity 1 874.774000 2.210 56.95 2008

2 Radial Velocity 1 763.000000 2.600 19.84 2011

3 Radial Velocity 1 326.030000 19.400 110.62 2007

4 Radial Velocity 1 516.220000 10.500 119.47 2009

i. Visualize the count of planets discovered in each year using factorplot and
barplot.
ii. Visualize the count of Method of discovery of each of these planets.

You might also like