Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to use the Series.product() function in pandas

Maria Elijah


The Series.product() function in pandas computes the product of the elements in the series.


Series.product(axis=None, skipna=True, level=None, numeric_only=None, min_count=0)


  • axis: This indicates the axis in which the operation is to be performed. The value 0 and 1 indicates rows and columns, respectively. The default is 0.
  • skipna: This is used to eliminate NAN or null values when calculating the result. The default is True.
  • level (optional): The default value is None. It represents the level to be broadcasted(in the case of multilevel).
  • numeric_only: Only float, int, and boolean columns are allowed. If there is None, it will try to use everything. Otherwise, it will just use numerical data. Not used during the Series.
  • min_count: This represents the minimum number of valid values needed to complete the operation. The default is 0.


The following code will demonstrate how to use the Series.product() function in pandas:

import pandas as pd
import numpy as np

# create Series 
my_series = pd.Series([17, np.nan, 28, 15, 23, 7, np.nan])
# compute the product of the series
# using product()
Finding the product of the values of a given series using Series.product() function


In the code above:

  • Line 5: We create the Series, my_series.

  • Line 9: We use the product() function to return the product of the Series elements.

Note: The NaN values are dropped by setting the skipna argument to True.



View all Courses

Keep Exploring