Call Functions on Pandas DataFrames Values
Let's find out how a pandas DataFrames works along with Python functions.
We'll cover the following...
Try it yourself
Try executing the code below to see the result.
import pandas as pd cities = pd.DataFrame([ ('Vienna', 'Austria', 1_899_055), ('Sofia', 'Bulgaria', 1_238_438), ('Tekirdağ', 'Turkey', 1_055_412), ], columns=['City', 'Country', 'Population']) def population_of(city): return cities[cities['City'] == city]['Population'] city = 'Tekirdağ' print(population_of(city))
How to retrieve specific data from a DataFrame
Explanation
The ...