Reputation: 814
I have a pandas DataFrame
and I'm looking for the min value in it.
print(df.loc[df['Price'].idxmin()])
It's working and i can print the whole 'line', This is the result:
Country Switzerland
City Zurich
Airport Zurich
Carrier Vueling Airlines
Type Direct
Date 2017-09-05T00:00:00
Price 12360
AirportId ZRH
Name: 97, dtype: object
Process finished with exit code 0
How can I print for example only the AirportId
column?
Thank you!
Upvotes: 2
Views: 3711
Reputation: 215
let's say this is your data frame:
your_df = pd.DataFrame(data={'Airport':['x','y','z'], 'type': ['A','B','C'],
'price':[5450, 5450, 15998]})
you can access th efirst column like this:
print your_df.loc[your_df['price'].idxmin()].values[0]
Upvotes: 0
Reputation: 32095
By filtering against it:
print(df.loc[df['Price'].idxmin()]['Airport'])
If you intend to write data into that cell, keep using loc
:
df.loc[df['Price'].idxmin(),'Airport']
Upvotes: 2