Histograms for ONGC - open, low, high and adjusted close
收藏Mendeley Data2024-04-29 更新2024-06-26 收录
下载链接:
https://data.mendeley.com/datasets/nr7whvc92c
下载链接
链接失效反馈官方服务:
资源简介:
The provided code performs data analysis and visualization on historical stock price data for the Oil and Natural Gas Corporation (ONGC) from a CSV file. The code utilizes the pandas library for data manipulation and matplotlib.pyplot for generating histograms to visualize the distribution of various price metrics. Loading Data: The code begins by importing the pandas library as pd and the matplotlib.pyplot library as plt. The file path of the CSV file containing the ONGC stock price data is specified. The data is loaded into a DataFrame named df using the read_csv() function from pandas. Extracting Required Columns: The code extracts the required columns from the DataFrame, including 'Open', 'High', 'Low', 'Close', and 'Adj Close' prices, and assigns them to separate variables. Summary Statistics: Summary statistics are computed for each extracted column using the describe() function, which provides metrics such as count, mean, standard deviation, minimum, 25th percentile, median, 75th percentile, and maximum values. Plotting Histograms: Histograms are created for each price metric ('Open', 'High', 'Low', 'Close', 'Adj Close') using the plt.hist() function. Each histogram is plotted in a separate subplot within a single figure using the plt.subplot() function. The number of bins for each histogram is set to 20 to visualize the distribution of prices across different ranges. Titles and labels are added to each subplot to provide context to the plotted data. Displaying Plots: The plt.tight_layout() function adjusts the spacing between subplots to prevent overlapping. Finally, the plt.show() function is called to display the histograms. Overall, the code efficiently analyzes the distribution of ONGC stock prices across different metrics and visualizes them using histograms, allowing for easy interpretation of the data's characteristics and patterns.
创建时间:
2024-04-25



