What does the expression df.loc['r4'] = [67, 78] do for the data frame df, defined below? df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

Questions & AnswersCategory: Programming LanguageWhat does the expression df.loc['r4'] = [67, 78] do for the data frame df, defined below? df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])
Adam asked 2 years ago

What does the expression df.loc[‘r4’] = [67, 78] do for the data frame df, defined below?

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

a. Over writes the last row
b. Adds a new row
c. Adds a column
d. Results in Error