0

I met the following loop header example:

for _, p in data.iterrows():

What does it mean? What is underscore and what is comma?

UPDATE

iterrows is from here: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iterrows.html

Dims
  • 47,675
  • 117
  • 331
  • 600
  • 1
    Underscore is an argument that has no name, a placeholder of sorts, so its declaring 2 args, _ and p. – Andrew Li Jun 02 '16 at 18:22
  • And what goes to these args? – Dims Jun 02 '16 at 18:25
  • _ and p are given data.iterrows();, probably a tuple with the variables representing the returned data respectively – Andrew Li Jun 02 '16 at 18:28
  • 2
    `data.iterrows()` would return a tuple containing two values [(1, 2), (3, 4), (5, 6)], etc. The underscore would be the first (1, 3, 5) while the p would be the second (2, 4, 6). It would most likely only be used as a placeholder if the first values were not needed but the values in p are. – duncan Jun 02 '16 at 18:29

0 Answers0