![]() |
The library in Python that allows users to analyze big data and work with datasets is known as Pandas. Pandas allow users to create the data frame or read from the CSV file using the read_csv function. Once you have created or imported the data, you can calculate various statistics from it, such as mean, median, mode, max, min, sum, etc. In this article, we will discuss calculating statistics from an imported CSV file using Pandas. Calculate Stats from an Imported CSV file using PandasImporting data from a CSV file:We can read the data from a CSV file using the read_csv function. Syntax:
We have read the CSV file using read_csv function. Then, we have calculated mean, median, mode, standard deviation, variance, etc. Python3
Output: name subject class fees fine There are various descriptive statistics, such as mean, median, mode, max, min, standard deviation, and variance, which we can calculate once we have the data. 1. Mean Value:The average of given datasets is known as mean value. There occurs various circumstances when we need to calculate the mean of a column in the dataset. We can calculate the mean as follows: Syntax:
Python3
Output: Mean Value: 14400.0 2. Median Value:The middle value of the dataset when arranged in ascending or descending order is known as median value. In a huge dataset, it is difficult to calculate the median on our own, hence we can calculate the median as follows: Syntax:
Python3
Output: Median Value: 15000.0 3. Mode Value:The value that occurs most frequently in the dataset is known as mode value. It is best used for examining the categorical data. We can calculate the mode as follows: Syntax:
Python3
Output: Mode Value: 18000 4. Minimum Value:The smallest value in the dataset is known as minimum value. The minimum value is used for various purposes, which can be calculated as follows: Syntax:
Python3
Output: Minimum Value: 9000 5. Maximum Value:The largest value in the dataset is known as maximum value. The maximum value is used for various purposes, which can be calculated as follows: Syntax:
Python3
Output: Maximum Value: 18000 6. Sum Value:The result after adding all the values in the dataset is known as sum value. The sum is the most common stastic, which can be calculated as follows: Syntax:
Python3
Output: Sum Value: 72000 7. Count Value:The way of determining the quantity of objects in dataset is known as count value. The count is the basic statistic, which is further used in various other statistics. We can calculate count value as follows: Syntax:
Python3
Output: Count Value: 5 8. Standard Deviation Value:The statistic measuring the dispersion of a dataset relative to its mean is known as standard deviation. It is rarely used in daily life. The standard deviation can be calculated as follows: Syntax:
Python3
Output: Standard Deviation Value: 3911.521443121589 9. Variance Value:The statistic measuring the spread between numbers in a data set is known as variance. It is used to group differences of certain values, which can be calculated as follows: Syntax:
Python3
Output: Variance Value: 15300000.0 |
Reffered: https://www.geeksforgeeks.org
Pandas |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |