appleLover
appleLover

Reputation: 15691

Pandas Data Frame, Select Subset

How can I put this code into one line?

game = data[(data.date==test_day)]
game = game.loc[game.index[0]]

Upvotes: 1

Views: 2911

Answers (2)

C Mars
C Mars

Reputation: 2979

I was just writing the same thing

game = data[(data.date==test_day)].iloc[game.index[0]]

Upvotes: 0

waitingkuo
waitingkuo

Reputation: 93754

Use iloc instead

data[data.date == test_day].iloc[0]

Upvotes: 3

Related Questions