-3

following is a preview of a marketing dataframe. Complete the code to get desired output

   id  views  clicks
a  1   1000   300
b  2   1200   800
c  3   800    200

output

   views  clicks
a  1000   300

what should i change in my code to get this output

import pandas as pd
market=pd.read_csv("marketing.csv")
print(market.iloc[0])
Ayushi midha
  • 35
  • 2
  • 13

1 Answers1

2

You can use iloc like this for your purpose. But you will get a Series

market.iloc[[0], [1, 2]]

or loc like this to get a dataframe

market.loc[['a'], ['views', 'clicks']]
Sreeram TP
  • 11,346
  • 7
  • 54
  • 108