Statistical Analysis of ONGC Stock

Published: 23 April 2024| Version 1 | DOI: 10.17632/c9nbg688tg.1
Sunil Maria Benedict


The provided data is sourced from a CSV file named 'ONGCprice.csv' and represents historical closing prices for a financial asset, likely the Oil and Natural Gas Corporation (ONGC) given the filename. The data is loaded into a DataFrame using the pandas library in Python for analysis and visualization. The first few rows of the DataFrame are displayed using the head() function to provide an initial glimpse into the dataset's structure and content. Summary statistics of the dataset are computed using the describe() function, which includes metrics such as count, mean, standard deviation, minimum, 25th percentile, median (50th percentile), 75th percentile, and maximum values for each numeric column in the DataFrame. These statistics offer insights into the central tendency, variability, and distribution of the closing prices over the given period. Additionally, specific calculations are performed on the closing price data: The average closing price is computed using the mean() function to determine the typical value of the asset over the observed period. The highest closing price is identified using the max() function, indicating the peak value reached by the asset during the period. The lowest closing price is determined using the min() function, representing the minimum value observed for the asset's closing price. Finally, a line plot of the closing prices is generated using the plot() function to visualize the trend and fluctuations in the asset's prices over time. The title of the plot is set as 'Closing Prices for ONGC' to provide context to the plotted data.


Steps to reproduce

import pandas as pd # Load the CSV file into a DataFrame df = pd.read_csv('ONGCprice.csv') # Display the first few rows of the DataFrame print("First few rows of the DataFrame:") print(df.head()) # Summary statistics print("\nSummary statistics:") print(df.describe()) # Calculate the average closing price average_price = df['Close'].mean() print("\nAverage closing price:", average_price) # Calculate the highest closing price max_price = df['Close'].max() print("Highest closing price:", max_price) # Calculate the lowest closing price min_price = df['Close'].min() print("Lowest closing price:", min_price) # Plot the closing prices df['Close'].plot(title='Closing Prices for ONGC')




Statistics, Statistician, Stock Price