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
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ applying-lambda-functions-to-pandas-dataframe
Applying Lambda functions to Pandas Dataframe - GeeksforGeeks
July 15, 2025 - In this example, we will apply the lambda function Dataframe.assign() to a single column. The function is applied to the 'Total_Marks' column, and a new column 'Percentage' is formed with its help. ... # importing pandas library import pandas as pd # creating and initializing a list values= [['Rohan',455],['Elvish',250],['Deepak',495], ['Soni',400],['Radhika',350],['Vansh',450]] # creating a pandas dataframe df = pd.DataFrame(values,columns=['Name','Total_Marks']) # Applying lambda function to find # percentage of 'Total_Marks' column # using df.assign() df = df.assign(Percentage = lambda x: (x['Total_Marks'] /500 * 100)) # displaying the data frame df
๐ŸŒ
ProjectPro
projectpro.io โ€บ blog โ€บ how to apply lambda functions to python pandas?
How To Apply Lambda Functions To Python Pandas?
October 28, 2024 - Applying Pandas agg with lambda functions is a powerful technique to perform multiple aggregations on DataFrame columns simultaneously. This method allows you to define custom operations easily.
๐ŸŒ
Medium
medium.com โ€บ @ratnesh3345 โ€บ day-25-pandas-day-6-mastering-apply-lambda-and-custom-functions-like-a-pro-๏ธ-b38d59d97fbc
Day 25 โ€” Pandas Day 6: Mastering Apply, Lambda, and Custom Functions Like a Pro โš™๏ธ | by Ratnesh | Medium
June 28, 2025 - Definition: apply() lets you apply a function to each element, row, or column. ... # consider that we are assuming anything above 10,000 is a high value order df["Is_High_Value"] = df["Amount"].apply(lambda x: x > 10000) It will return a boolean ...
๐ŸŒ
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 ... '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 ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.apply.html
pandas.DataFrame.apply โ€” pandas 3.0.6 documentation
Passing result_type='broadcast' will ensure the same shape result, whether list-like or scalar is returned by the function, and broadcast it along the axis. The resulting column names will be the originals. >>> df.apply(lambda x: [1, 2], axis=1, result_type="broadcast") A B 0 1 2 1 1 2 2 1 2 ยท Advanced users can speed up their code by using a Just-in-time (JIT) compiler with apply. The main JIT compilers available for pandas are Numba and Bodo.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas apply() with lambda examples
Pandas apply() with Lambda Examples - Spark By {Examples}
June 17, 2025 - pandas.DataFrame.apply() can be used along with the Python lambda function to apply a custom operation to all columns in a DataFrame. A lambda function is
๐ŸŒ
Arabpsychology
statistics.arabpsychology.com โ€บ psychological statistics โ€บ learning pandas: applying custom functions with lambda expressions
Learning Pandas: Applying Custom Functions With Lambda Expressions - PSYCHOLOGICAL STATISTICS
October 29, 2025 - When paired, .apply() uses the lambda function to define the operation performed on each item of the Series. This pairing allows for incredibly expressive and efficient inline application of custom logic. Consider the general syntax for applying conditional logic to a Pandas Series, where the ...
Find elsewhere
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.Series.apply.html
pandas.Series.apply โ€” pandas 3.0.6 documentation - PyData |
Square the values by passing an anonymous function as an argument to apply(). >>> s.apply(lambda x: x**2) London 400 New York 441 Helsinki 144 dtype: int64 ยท Define a custom function that needs additional positional arguments and pass these additional arguments using the args keyword.
๐ŸŒ
Medium
medium.com โ€บ @amit25173 โ€บ understanding-lambda-functions-in-pandas-e4588c53cc89
Understanding Lambda Functions in Pandas | by Amit Yadav | Medium
March 6, 2025 - ... Let me break it down: the apply() function is like a messenger. It takes your custom function (in this case, a lambda) and delivers it to each element in a Pandas Series or DataFrame.
๐ŸŒ
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)
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ using-apply-in-pandas-lambda-functions-with-multiple-if-statements
Using Apply in Pandas Lambda functions with multiple if statements - GeeksforGeeks
June 20, 2025 - This will be used to classify students using custom logic. Lambda functions in apply() are ideal for simple conditions such as pass/fail classification. ... import pandas as pd df = pd.DataFrame({'Name': ['John', 'Jack', 'Shri', 'Krishna', 'Smith', ...
๐ŸŒ
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.
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ most powerful python functions apply() and lambda()
Most powerful Python Functions apply() and lambda() - Analytics Vidhya
October 19, 2024 - Because you just need to care about the custom function, you should be able to design pretty much any logic with apply/lambda. Filtering and subsetting data frames are simple with Pandas.
๐ŸŒ
VDCI
vdci.edu โ€บ transforming dataframes with apply and lambda functions
Transforming DataFrames with Apply and Lambda Functions - Free Video Tutorial
May 19, 2025 - Create a DataFrame with a "numbers" column from 10,000 to 10,010 and transform it using apply with functions (like add_five and add_sets), then chain them or replace with lambda functions for concise transformations. ... Learn how to efficiently transform data in a Pandas DataFrame using the apply function to run custom transformations on each item in a column.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ pandas: how to use apply & lambda together
Pandas: How to Use Apply & Lambda Together
June 23, 2022 - #modify existing 'points' column df['points'] = df['points'].apply(lambda x: x/2 if x < 20 else x*2) #view updated DataFrame print(df) team points assists 0 A 9.0 5 1 B 44.0 7 2 C 9.5 7 3 D 7.0 9 4 E 7.0 12 5 F 5.5 9 6 G 40.0 9 7 H 56.0 4 ยท In this example, we modified the values in the existing points column by using the following rule in the lambda function:
๐ŸŒ
Pandas
pandas.pydata.org โ€บ pandas-docs โ€บ stable โ€บ reference โ€บ api โ€บ pandas.Series.apply.html
pandas.Series.apply โ€” pandas 2.2.2 documentation - PyData |
Square the values by passing an anonymous function as an argument to apply(). >>> s.apply(lambda x: x**2) London 400 New York 441 Helsinki 144 dtype: int64 ยท Define a custom function that needs additional positional arguments and pass these additional arguments using the args keyword.
๐ŸŒ
Stack Exchange
datascience.stackexchange.com โ€บ questions โ€บ 75556 โ€บ update-a-pandas-data-frame-column-using-apply-lambda-and-group-by-functions
python - Update a pandas data frame column using Apply,Lambda and Group by Functions - Data Science Stack Exchange
June 6, 2020 - I used 'Apply' function to every row in the pandas data frame and created a custom function to return the value for the 'Candidate Won' Column using data frame,row-level 'Constituency','% of Votes' Custom Function Code: def update_candidateresult(df,a,b): max_voteshare=df.groupby(df['Constituency']==a)['% of Votes'].max()[True] if b==max_voteshare: return "won" else: return "loss" Final Code : df_andhrapradesh['Candidate Won']=df_andhrapradesh.apply(lambda row:update_candidateresult(df_andhrapradesh,row['Constituency'],row['% of Votes']),axis=1) Share ยท
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ pandas โ€บ pandas-custom-functions-and-apply-exercises.php
Pandas Custom Functions Exercises - Apply, Map, and Applymap
Write a Pandas program that apply a custom function to each column using apply() function. ... Write a Pandas program that uses map() function to apply a function to a Series. ... Write a Pandas program that applies different functions on DataFrame ...