Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: a series named heights_A with values 176.2, 158.4, 167.6, 156.2, and 161.4. These values represent heights of 5 students of class A. Label each

Question:

a series named heights_A with values 176.2, 158.4, 167.6, 156.2, and 161.4. These values represent heights of 5 students of class A.

Label each student as s1, s2, s3, s4, and s5.

another series named weights_A with values 85.1, 90.2, 76.8, 80.4, and 78.9. These values represent weights of 5 students of class A.

Label each student as s1, s2, s3, s4, and s5.

a dataframe named df_A, which holds the height and weight of five students s1, s2, s3, s4 and s5.

Label the columns as Student_height and Student_weight, respectively.

Select the rows corresponding to students s1, s2 and s5 of df_A in the order s2, s5, s1, and capture them in another dataframe df_s2s5s1.

Print the dataframe df_s2s5s1

Wrote to this point on this:

import pandas as pd import numpy as np heights_A = pd.Series([176.2, 158.4, 167.6, 156.2, 161.4]) heights_A.index = ['s1', 's2', 's3', 's4','s5'] weights_A = pd.Series([85.1, 90.2, 76.8, 80.4 , 78.9]) weights_A.index = ['s1', 's2', 's3', 's4','s5'] df_A = pd.DataFrame() df_A['Student_height'] = heights_A df_A['Student_weight'] = weights_A df_s2s5s1 = df_A.loc[(df_A.index.str.endswith('2') | df_A.index.str.endswith('5') | df_A.index.str.endswith('1') ] print(df_s2s5s1) 

But this is not in order of 2,5,1. Could you help on how to get these in order as such.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions