Answer to Question #147697 in Python for Joseph Se

Question #147697
Which of the following statements is incorrect?

A. We can use s.iteritems() on a pd.Series object s toiterate on it

B. If s and s1 are two pd.Series objects, we cannot use s.append(s1) to directly append s1 to the existing series s

C. loc and iloc are two useful and commonly used pandas method

D. If s is a pd.Series object, then we can use s.loc[label] to get all the data where the index is equal label
1
Expert's answer
2020-12-03T14:37:15-0500

The wrong answer is B. We can use s.append(s1) to directly append s1 to the existing series s. See example below.

import pandas as pd
import numpy as np


#create and print first series
data = np.array(['a','b','c','d'])  
s = pd.Series(data,index=[100,101,102,103])
print('First series: \n',s)
print()


#create and print second series
data = {'a' : 0., 'b' : 1., 'c' : 2.}
s1 = pd.Series(data)
print('Second series: \n',s1)
print()


#append and print combined series
print('Appended series: \n',s.append(s1))

Answer. B.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS