Use pd.DataFrame.apply()
, as below:
df['d'] = df.apply(lambda x: some_func(a = x['a'], b = x['b'], c = x['c']), axis=1)
NOTE: As @ashishsingal asked about columns, the axis
argument should be provided with a value of 1, as the default is 0 (as in the documentation and copied below).
axis : {0 or ‘index’, 1 or ‘columns’}, default 0
- 0 or ‘index’: apply function to each column
- or ‘columns’: apply function to each row
Related Contents:
- Delete a column from a Pandas DataFrame
- Filter dataframe rows if value in column is in a set list of values [duplicate]
- Convert DataFrame column type from string to datetime
- How to select rows with one or more nulls from a pandas DataFrame without listing columns explicitly?
- Merge two dataframes by index
- pandas DataFrame: replace nan values with average of columns
- How can I map True/False to 1/0 in a Pandas DataFrame?
- pandas get column average/mean
- check if variable is dataframe
- How to add value labels on a bar chart
- How do I create a new column from the output of pandas groupby().sum()?
- Python: get a frequency count based on two columns (variables) in pandas dataframe some row appers
- pandas – add new column to dataframe from dictionary [duplicate]
- how to test if a variable is pd.NaT?
- Apply Function on DataFrame Index
- How to import data from mongodb to pandas?
- Python Pandas: Convert Rows as Column headers [duplicate]
- Is there a way to copy only the structure (not the data) of a Pandas DataFrame?
- Pandas timeseries plot setting x-axis major and minor ticks and labels
- Pandas read_sql with parameters
- List of Tuples to DataFrame Conversion [duplicate]
- How to sort pandas data frame using values from several columns?
- Color by Column Values in Matplotlib
- HDF5 – concurrency, compression & I/O performance [closed]
- Is it possible to append Series to rows of DataFrame without making a list first?
- Replace all occurrences of a string in a pandas dataframe (Python)
- Generating random dates within a given range in pandas
- How do I round datetime column to nearest quarter hour
- Pandas: Converting to numeric, creating NaNs when necessary
- Python: using multiprocessing on a pandas dataframe
- pandas replace multiple values one column
- Programmatically convert pandas dataframe to markdown table
- Pandas DataFrame merge summing column
- How to delete all rows in a dataframe?
- ExcelFile Vs. read_excel in pandas
- How to read a file with a semi colon separator in pandas
- pandas merge dataframe with NaN (or “unknown”) for missing values
- How to divide two columns element-wise in a pandas dataframe
- replace() method not working on Pandas DataFrame
- Adding a column in pandas df using a function
- Reverse a get_dummies encoding in pandas
- Pip Install Timeout Issue
- How to get a single value as a string from pandas dataframe
- How to drop columns which have same values in all rows via pandas or spark dataframe?
- Counting consecutive positive values in Python/pandas array
- Python Pandas does not read the first row of csv file
- Filtering pandas dataframe with multiple Boolean columns
- Equality in Pandas DataFrames – Column Order Matters?
- How can I create the minimum size executable with pyinstaller?
- Pandas ParserError EOF character when reading multiple csv files to HDF5