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,601
  • 8
  • 38
  • 51
  • As far as I know, no different, but keeping the ,: for column is good habit , I think – BENY Dec 01 '17 at 15:35
  • In this case, both are the same. No colon implicitly assign the conditions for the first dim. – dkato Dec 01 '17 at 15:41
  • Answer this `"dfdd"[:]`, `"dfdd"` whats the difference – Bharath Dec 01 '17 at 15:44
  • There isn't much difference between thing specified in this link https://stackoverflow.com/questions/509211/understanding-pythons-slice-notation and the question. – Bharath Dec 01 '17 at 15:52

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