1

Say I have the following dataframe:

In [1]: df = pd.DataFrame({ 'one' : [11, 12, 13], 'two' : [21, 22, 23]})

In [2]: df
Out[2]:
   one  two
0   11   21
1   12   22
2   13   23

Is there any difference between using a colon or not when selecting all colums? e.g.

In [3]: df.loc[ df.two > 22, :]
Out[3]:
   one  two
2   13   23

vs

In [4]: df.loc[ df.two > 22]
Out[4]:
   one  two
2   13   23

?

Thanks

Carmellose
  • 4,815
  • 10
  • 38
  • 56

1 Answers1

2

No difference. Only difference if you write column name just before or/and after colon.

In[10]: df.loc[ df.two > 22, 'one':'one']
Out[10]: 
   one
2   13
Lucas
  • 36
  • 3