Question: Let df be a pandas DataFrame constructed with the followingcode: data = np.array([0, 7, 3, 6, 2, 8, 5, 9, 4]).reshape(3, -1) df = pd.DataFrame(data,

Let df be a pandas DataFrame constructed with the followingcode:

data = np.array([0, 7, 3, 6, 2, 8, 5, 9, 4]).reshape(3, -1)

df = pd.DataFrame(data, index=['One', 'Two', 'Three'],columns=['a', 'b', 'c'])

What is the output of the following code? Please append withdetailed comments about why.

a. print(df)

b. df[‘a’]

c. df[‘One’]

d. df.loc[‘Two’]

e. df[:2]

f. df.iloc[:,:2]

g. list(df.columns)

h. list(df.index)

i. df[‘b’][‘Two’]

j. list(df.iloc[2, :]) [1%]

k. df.drop('a', axis=1)

l. df[df.a !=5]

m. list(df.sum(axis=0))

n. df.iloc[:, list(df.sum(axis=0) < 17)]

o. df.sort_values(by='c')

p. df.sort_values(by='Two', axis=1) [1%]

q. df.T

r. (df<=2).any(axis=0)

s. df.applymap(lambda x: x*2-1)

t. df.apply(lambda x: max(x), axis=1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!