You can just sum and set axis=1 to sum the rows, which will ignore non-numeric columns; from pandas 2.0+ you also need to specify numeric_only=True.

In [91]:

df = pd.DataFrame({'a': [1,2,3], 'b': [2,3,4], 'c':['dd','ee','ff'], 'd':[5,9,1]})
df['e'] = df.sum(axis=1, numeric_only=True)
df
Out[91]:
   a  b   c  d   e
0  1  2  dd  5   8
1  2  3  ee  9  14
2  3  4  ff  1   8

If you want to just sum specific columns then you can create a list of the columns and remove the ones you are not interested in:

In [98]:

col_list= list(df)
col_list.remove('d')
col_list
Out[98]:
['a', 'b', 'c']
In [99]:

df['e'] = df[col_list].sum(axis=1)
df
Out[99]:
   a  b   c  d  e
0  1  2  dd  5  3
1  2  3  ee  9  5
2  3  4  ff  1  7

sum docs

Answer from EdChum on Stack Overflow
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas sum dataframe rows with examples
Pandas Sum DataFrame Rows With Examples - Spark By {Examples}
December 3, 2024 - To sum all Pandas DataFrame rows or given selected rows use the sum() function. The Pandas DataFrame.sum() function returns the sum of the values for the
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-sum-values-of-pandas-dataframe-by-rows
How to sum values of Pandas dataframe by rows? - GeeksforGeeks
March 26, 2021 - Pandas dataframe.sum() function returns the sum of the values for the requested axis. ... Summing all the rows of a Dataframe using the sum function and setting the axis value to 1 for summing up the row values and displaying the result as output.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-dataframe-sum
Pandas dataframe.sum() - GeeksforGeeks
July 11, 2025 - Explanation: Instead of adding up values in columns, this example sums up values in each row. First, it selects only numeric columns to avoid errors. Missing values are ignored during the summation. The min_count parameter ensures that the sum operation is performed only if at least a certain number of non-NaN values are present. Otherwise, the result will be NaN. ... import pandas as pd import numpy as np data = {'A': [1, np.nan, 3, np.nan], 'B': [4, np.nan, np.nan, np.nan], 'C': [7, 8, 9, np.nan]} df = pd.DataFrame(data) # Sum columns but require at least 2 valid values df_sum_min_count = df.sum(axis=0, min_count=2) print("\nSum with min_count=2:") print(df_sum_min_count)
🌐
W3Schools
w3schools.com › python › pandas › ref_df_sum.asp
Pandas DataFrame sum() Method
import pandas as pd data = [[10, 18, 11], [13, 15, 8], [9, 20, 3]] df = pd.DataFrame(data) print(df.sum()) Try it Yourself » · The sum() method adds all values in each column and returns the sum for each column.
🌐
Medium
medium.com › @amit25173 › understanding-pandas-dataframe-sum-a23521d6937b
Understanding pandas.DataFrame.sum() | by Amit Yadav | Medium
March 6, 2025 - If you want to sum the rows, set axis=1. skipna: By default, this is set to True. It means that if there are any missing (NaN) values in your DataFrame, pandas will ignore them when performing the sum.
🌐
Programiz
programiz.com › python-programming › pandas › methods › sum
Pandas sum() (With Examples)
import pandas as pd # create a DataFrame df = pd.DataFrame({ 'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9] }) # calculate the sum of each column column_sum = df.sum() # calculate the sum of each row row_sum = df.sum(axis=1) print("Sum of each column:") print(column_sum) print("\nSum of each row:") print(row_sum) Output ·
Find elsewhere
🌐
Saturn Cloud
saturncloud.io › blog › how-to-sum-values-of-a-row-of-a-pandas-dataframe-efficiently
Efficient Techniques for Summing Row Values in Pandas Dataframes | Saturn Cloud Blog
May 1, 2026 - The most efficient way to sum values of a row of a pandas dataframe is to use the sum() method with the axis parameter set to 1. The axis parameter specifies whether to sum the rows (0) or the columns (1).
🌐
Statology
statology.org › home › how to sum specific rows in pandas (with examples)
How to Sum Specific Rows in Pandas (With Examples)
September 27, 2022 - The sum of rows with index values ‘A’, ‘B’, and ‘E’ for the points column is 68. The sum of rows with index values ‘A’, ‘B’, and ‘E’ for the rebounds column is 25.
🌐
datagy
datagy.io › home › pandas tutorials › data analysis in pandas › pandas sum: add dataframe columns and rows
Pandas Sum: Add Dataframe Columns and Rows • datagy
December 15, 2022 - In many cases, you’ll want to add up values across rows in a Pandas Dataframe. Similar to the example above, we can make use of the .sum method. By default, Pandas will apply an axis=0 argument, which will add up values index-wise.
🌐
TutorialsPoint
tutorialspoint.com › article › python-summing-all-the-rows-of-a-pandas-dataframe
Python - Summing all the rows of a Pandas Dataframe
September 14, 2021 - To sum all the rows of a DataFrame, use the sum() function with axis=1. Setting the axis parameter to 1 adds values across columns for each row, while axis=0 (default) would sum down columns.
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to sum all the rows of a pandas dataframe in python
5 Best Ways to Sum All the Rows of a Pandas DataFrame in Python - Be on the Right Side of Change
March 5, 2024 - Combining Numpy’s sum function right within the DataFrame constructor is a slick one-liner that can yield a new DataFrame containing the row sums. It’s a quick and effective method when we need to preserve the result as DataFrame. ... import pandas as pd import numpy as np # Create a DataFrame df = pd.DataFrame({'A': [1, 4, 7], 'B': [2, 5, 8], 'C': [3, 6, 9]}) # One-liner to sum rows and preserve as DataFrame row_sum_df = pd.DataFrame(np.sum(df, axis=1), columns=['Sum']) print(row_sum_df)
🌐
Vultr Docs
docs.vultr.com › python › third party › pandas › dataframe › sum()
Python Pandas DataFrame sum() - Sum Column Values
December 25, 2024 - The sum() function in Python's Pandas library is a crucial tool for performing aggregation operations on DataFrame columns. This method sums up the values in each column by default, or along the rows if specified, facilitating quick statistical ...
🌐
Statistics Globe
statisticsglobe.com › home › python programming language for statistics & data science › sum of columns & rows of pandas dataframe in python (2 examples)
Sum of Columns & Rows of pandas DataFrame in Python (2 Examples)
May 11, 2023 - Have a look at the previous table. It shows that our example data consists of eight rows and three columns called “x1”, “x2”, and “x3”. The following Python code explains how to get the column sums of all numeric variables of a pandas DataFrame in Python.
🌐
Plus2Net
plus2net.com › python › pandas-dataframe-sum.php
Python Pandas DataFrame sum() For suming rows and columns by using axis , skipna,numeric_only,min_count levels
We can sum number of in rows or columns by using sum(). import pandas as pd my_dict={'NAME':['Ravi','Raju','Alex','Ron','King','Jack'], 'ID':[1,2,3,4,5,6], 'MATH':[80,40,70,70,70,30], 'ENGLISH':[80,70,40,50,60,30]} my_data = pd.DataFrame(da...