1

I have a data frame(df1) like the below:

    A   B   C   D
0  a0  b0  c0  d0
1  a1  b1  c1  d1
2  a2  b2  c2  d2
3  a3  b3  c3  d3

I did the drop operation:

df1.drop([0],inplace=True)

so the data frame like this:

    A   B   C   D
1  a1  b1  c1  d1
2  a2  b2  c2  d2
3  a3  b3  c3  d3

after that when I check

df.iloc[[0]]

This is the result:

    A   B   C   D
1  a1  b1  c1  d1

I am confused, I am expecting a Null Data frame, why is it showing index 1 output?

Van Peer
  • 2,127
  • 2
  • 25
  • 35
Bhanu Tez
  • 296
  • 2
  • 14
  • 1
    df.iloc[[0]] is query the position , you are looking for .loc – BENY Jul 24 '18 at 02:41
  • `df1.drop([0],inplace=True)` removes the 0th row. See documentation: [http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html?highlight=drop][1] Therefore when you make a row call like `df.iloc[[0]]` The result is A B C D 1 a1 b1 c1 d1 [1]: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html?highlight=drop – PydPiper Jul 24 '18 at 02:45

0 Answers0