I want to apply a custom function and create a derived column called population2050 that is based on two columns already present in my data frame.
import pandas as pd
import sqlite3
conn = sqlite3.connect('factbook.db')
query = "select * from facts where area_land =0;"
facts = pd.read_sql_query(query,conn)
print(list(facts.columns.values))
def final_pop(initial_pop,growth_rate):
final = initial_pop*math.e**(growth_rate*35)
return(final)
facts['pop2050'] = facts['population','population_growth'].apply(final_pop,axis=1)
When I run the above code, I get an error. Am I not using the 'apply' function correctly?