You were almost there:

facts['pop2050'] = facts.apply(lambda row: final_pop(row['population'],row['population_growth']),axis=1)

Using lambda allows you to keep the specific (interesting) parameters listed in your function, rather than bundling them in a 'row'.

Answer from Karnage on Stack Overflow
🌐
Medium
medium.com › @antoniolui › applying-custom-functions-in-pandas-e30bdc1f4e76
Applying Custom Functions in Pandas | by Tony Lui | Medium
September 20, 2022 - Let’s start by creating an sample Pandas DataFrame: df = pd.DataFrame([[1, 2, 'cat', []] ,[3, 4, 'dog', [1,2,3]] ,[5, 1, np.nan, [3,5,5]]], columns=['A', 'B', 'C', 'D']) For starters, let’s apply a dictionary value mapping to column C: df['C'] = df['C'].map({'cat': 'kitten', 'dog': 'puppy'}) For simple custom functions that can be expressed in a lambda function, you can easily apply them to a Pandas series/column through:
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.apply.html
pandas.Series.apply — pandas 3.0.6 documentation - PyData |
>>> s.apply(subtract_custom_value, args=(5,)) London 15 New York 16 Helsinki 7 dtype: int64 · Define a custom function that takes keyword arguments and pass these arguments to apply.
🌐
Medium
chrisyandata.medium.com › leveraging-custom-functions-with-the-apply-method-in-pandas-dataframe-9cc5b20d1adb
Leveraging Custom Functions with the Apply Method in Pandas DataFrame | by Chris Yan | Medium
December 31, 2024 - Introduction: Pandas, a popular ... structures. One such tool is the apply() method, which allows developers to apply custom functions to DataFrame columns or rows efficiently....
🌐
PythonForBeginners.com
pythonforbeginners.com › home › pandas apply function to dataframe or series
Pandas Apply Function to Dataframe or Series - PythonForBeginners.com
January 11, 2023 - You can pass a user-defined function to the applymap() method to apply a custom function on the pandas dataframe as shown below.
🌐
Towards Data Science
towardsdatascience.com › home › latest › applying custom functions to groups of data in pandas
Applying Custom Functions to Groups of Data in Pandas | Towards Data Science
March 5, 2025 - Simply use the apply method to each dataframe in the groupby object. This is the most straightforward way and the easiest to understand. Notice that the function takes a dataframe as its only argument, so any code within the custom function ...
Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.apply.html
pandas.DataFrame.apply — pandas 3.0.6 documentation
However if the apply function returns a Series these are expanded to columns. ... Positional arguments to pass to func in addition to the array/series. ... Only has an effect when func is a listlike or dictlike of funcs and the func isn’t a string. If “compat”, will if possible first translate the func into pandas methods (e.g.
🌐
Pandas
pandas.pydata.org › docs › dev › user_guide › user_defined_functions.html
User-Defined Functions (UDFs) — pandas 3.1.0.dev0 documentation
The agg method is used to aggregate a set of data points into a single one. The most common aggregation functions such as min, max, mean, sum, etc. are already implemented in pandas. agg allows to implement other custom aggregate functions.
🌐
HopHR
hophr.com › tutorial-page › efficiently-apply-custom-functions-pandas-dataframe-columns-step-by-step-guide
How to efficiently apply custom functions to pandas DataFrame columns? | HopHR
This function should take a single argument, which will be a column of your DataFrame. Here is an example of a function that multiplies its input by 2: ... Step 4: Apply the function to a DataFrame column You can now apply your custom function to a column of your DataFrame using the apply method.
🌐
w3resource
w3resource.com › python-exercises › pandas › pandas-custom-functions-and-apply-exercises.php
Pandas Custom Functions Exercises - Apply, Map, and Applymap
Learn how to use Pandas custom functions with apply(), map(), and applymap() for element-wise, row-wise, and column-wise operations with hands-on exercises and solutions.
🌐
GeeksforGeeks
geeksforgeeks.org › python › apply-a-function-to-each-row-or-column-in-dataframe-using-pandas-apply
Apply a function to each row or column in Dataframe using pandas.apply() - GeeksforGeeks
July 15, 2025 - In this example, we’ll apply a lambda function that adds 10 to each value in every column of the DataFrame. ... import pandas as pd import numpy as np # Creating a list of tuples for the DataFrame matrix = [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)] # Creating the DataFrame df = pd.DataFrame(matrix, columns=list('abcd')) # Output the DataFrame print("Original DataFrame:") print(df) print('\n') # Applying lambda function to add 10 to each value in every column new_df = df.apply(lambda x: x + 10) print("New DataFrame:") print(new_df)
🌐
Stack Abuse
stackabuse.com › efficient-data-manipulation-with-apply-function-in-pandas
Efficient Data Manipulation with Apply() Function in Pandas
July 5, 2023 - In summary, the apply() function serves as a valuable resource for data manipulation, especially in routine tasks that require repetitive code. This function allows for seamless integration of custom or built-in functions with Pandas Series and DataFrames.
🌐
Medium
medium.com › data-science › applying-custom-functions-to-groups-of-data-in-pandas-928d7eece0aa
Applying Custom Functions to Groups of Data in Pandas | by Casey Whorton | TDS Archive | Medium
July 22, 2021 - Simply use the apply method to each dataframe in the groupby object. This is the most straightforward way and the easiest to understand. Notice that the function takes a dataframe as its only argument, so any code within the custom function ...
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.apply.html
pandas.Series.apply — pandas 2.2.2 documentation - PyData |
>>> s.apply(subtract_custom_value, args=(5,)) London 15 New York 16 Helsinki 7 dtype: int64 · Define a custom function that takes keyword arguments and pass these arguments to apply.
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "python pandas howtos" › "how to apply a function to a column in pandas dataframe"
How to Apply a Function to a Column in Pandas Dataframe | Delft Stack
February 5, 2025 - The apply() method applies the function along a specified axis. It passes the columns as a dataframe to the custom function, whereas a transform() method passes individual columns as pandas Series to the custom function.
🌐
Medium
aws.plainenglish.io › panda-apply-and-groupby-12bb4b6105d4
Panda: apply() and groupby() | AWS in Plain English
October 21, 2024 - Pandas’ apply() function is a powerful tool that allows users to apply custom functions along either axis (rows or columns) of a DataFrame.
🌐
Techietory
techietory.com › home › data science › pandas apply function: transform your data
Pandas Apply Function: Transform Your Data with Custom Functions and Examples
February 20, 2026 - This is exactly where apply() comes in. The apply() function is Pandas’ mechanism for applying any arbitrary Python function — built-in, lambda, or custom-defined — to a Series, to columns of a DataFrame, or to rows of a DataFrame.