Math Operations for Data Analysis:

Some important math operations can be performed on pandas series for simplifying data analysis using Python and saving time in Data Science.

Now let us look at some functions and their uses.

  • s.sum() – This will return the sum of all the values in the series.
  • s.mean() – It will return the mean of all values in series. This is equal to s.sum() and s.count().
  • s.std() – It will return the standard deviation of all values.
  • s.min() or s.max() – It will return the min or max values from the series.
  • s.idmin() or s.idmax() – This will return index of min or max value in series.
  • s.median() – It will return the median of all values.
  • s.mode – It will return the mode of the series.
  • s.value_counts() – It will return the series with the frequency of each value.Math Operation for Data Analysis/Science in Python - PST Analytics
  • s.describe() – It will return a series with information like mean, mode, etc. which depends on the dtype of the data passed.

Code 1:

Math Operation for Data Analysis/Science in Python - PST Analytics

Math Operation for Data Analysis/Science in Python - PST Analytics

Code 2:

Math Operation for Data Analysis/Science in Python - PST Analytics

Unexpected Outputs and Restrictions:

  1. .sum(), .mean(), .mode(), .median() and other mathematical operations do not apply on string or any other data type other than numeric value.
  2. .sum() on a string series will give unexpected output, and it will return a string by concatenation of every string.

So, to learn more about python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.