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

Expert's answer

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.


LATEST TUTORIALS
APPROVED BY CLIENTS