Dataset Viewer
Auto-converted to Parquet Duplicate
date
stringdate
2013-02-08 00:00:00
2018-02-07 00:00:00
open
float64
1.62
2.04k
high
float64
1.69
2.07k
low
float64
1.5
2.04k
close
float64
1.59
2.05k
volume
int64
0
618M
Name
stringclasses
505 values
2013-02-08
15.07
15.12
14.63
14.75
8,407,500
AAL
2013-02-11
14.89
15.01
14.26
14.46
8,882,000
AAL
2013-02-12
14.45
14.51
14.1
14.27
8,126,000
AAL
2013-02-13
14.3
14.94
14.25
14.66
10,259,500
AAL
2013-02-14
14.94
14.96
13.16
13.99
31,879,900
AAL
2013-02-15
13.93
14.61
13.93
14.5
15,628,000
AAL
2013-02-19
14.33
14.56
14.08
14.26
11,354,400
AAL
2013-02-20
14.17
14.26
13.15
13.33
14,725,200
AAL
2013-02-21
13.62
13.95
12.9
13.37
11,922,100
AAL
2013-02-22
13.57
13.6
13.21
13.57
6,071,400
AAL
2013-02-25
13.6
13.76
13
13.02
7,186,400
AAL
2013-02-26
13.14
13.42
12.7
13.26
9,419,000
AAL
2013-02-27
13.28
13.62
13.18
13.41
7,390,500
AAL
2013-02-28
13.49
13.63
13.39
13.43
6,143,600
AAL
2013-03-01
13.37
13.95
13.32
13.61
7,376,800
AAL
2013-03-04
13.5
14.07
13.47
13.9
8,174,800
AAL
2013-03-05
14.01
14.05
13.71
14.05
7,676,100
AAL
2013-03-06
14.52
14.68
14.25
14.57
13,243,200
AAL
2013-03-07
14.7
14.93
14.5
14.82
9,125,300
AAL
2013-03-08
14.99
15.2
14.84
14.92
10,593,700
AAL
2013-03-11
14.85
15.15
14.71
15.13
6,961,800
AAL
2013-03-12
15.14
15.6
14.95
15.5
8,999,100
AAL
2013-03-13
15.54
16.2
15.48
15.91
11,380,000
AAL
2013-03-14
15.98
16.36
15.93
16.25
8,383,300
AAL
2013-03-15
16.45
16.54
15.88
15.98
17,667,700
AAL
2013-03-18
15.8
16.33
15.71
16.29
6,514,100
AAL
2013-03-19
16.48
16.85
16.41
16.78
11,805,300
AAL
2013-03-20
17.13
17.33
16.87
17.23
10,819,800
AAL
2013-03-21
17.21
17.43
16.87
17
10,740,800
AAL
2013-03-22
17.1
17.29
16.77
16.86
8,545,200
AAL
2013-03-25
16.92
17
16.35
16.6
8,400,000
AAL
2013-03-26
16.67
16.84
16.5
16.51
6,898,500
AAL
2013-03-27
16.48
16.77
16.33
16.65
5,537,100
AAL
2013-03-28
17
17.09
16.82
16.97
8,324,100
AAL
2013-04-01
17.02
17.13
16.54
16.67
5,222,300
AAL
2013-04-02
16.48
16.5
15.71
15.74
14,595,600
AAL
2013-04-03
15.82
15.92
15.13
15.53
14,658,300
AAL
2013-04-04
15.12
15.71
15.12
15.69
5,520,300
AAL
2013-04-05
15.17
15.79
15.03
15.72
5,252,300
AAL
2013-04-08
15.82
15.97
15.53
15.84
3,780,700
AAL
2013-04-09
16.07
16.1
15.67
15.7
4,420,200
AAL
2013-04-10
15.74
15.98
15.7
15.78
3,650,600
AAL
2013-04-11
15.77
16.38
15.75
16.19
5,062,200
AAL
2013-04-12
16.11
16.39
15.95
16.14
3,751,800
AAL
2013-04-15
16.2
16.39
15.47
15.59
6,243,400
AAL
2013-04-16
15.96
16.74
15.81
16.37
10,458,200
AAL
2013-04-17
16.17
16.55
15.9
16.52
6,581,900
AAL
2013-04-18
16.54
16.54
15.95
16.1
7,633,300
AAL
2013-04-19
16.1
16.24
15.85
16.02
5,762,600
AAL
2013-04-22
15.99
16
15.5
15.52
9,227,100
AAL
2013-04-23
15.33
16.49
15.33
16.3
12,302,300
AAL
2013-04-24
16.26
16.5
16
16.45
6,114,400
AAL
2013-04-25
16.55
16.73
16.19
16.22
5,548,800
AAL
2013-04-26
16.38
16.73
16.16
16.59
7,272,100
AAL
2013-04-29
16.7
16.97
16.56
16.81
5,436,400
AAL
2013-04-30
16.8
17.05
16.57
16.9
3,640,700
AAL
2013-05-01
16.91
17.17
16.6
16.6
4,943,600
AAL
2013-05-02
16.72
16.98
16.6
16.94
4,888,900
AAL
2013-05-03
17.02
17.19
16.89
17.02
6,451,900
AAL
2013-05-06
17.05
17.11
16.91
17
3,930,700
AAL
2013-05-07
17.15
17.15
16.95
16.98
3,157,000
AAL
2013-05-08
17.01
17.55
16.99
17.34
6,706,200
AAL
2013-05-09
17.53
17.86
17.34
17.38
6,424,000
AAL
2013-05-10
17.61
17.81
17.41
17.76
4,248,200
AAL
2013-05-13
17.74
17.95
17.57
17.72
4,250,900
AAL
2013-05-14
17.82
18.3
17.8
18.1
5,989,700
AAL
2013-05-15
18.37
18.99
18.31
18.81
8,951,500
AAL
2013-05-16
18.96
19.52
18.88
19.12
6,679,300
AAL
2013-05-17
19.38
19.7
18.75
19.01
7,540,000
AAL
2013-05-20
19.05
19.39
18.39
18.59
6,055,000
AAL
2013-05-21
18.55
18.7
17.65
17.95
10,018,700
AAL
2013-05-22
18.06
18.43
17.71
17.93
8,662,000
AAL
2013-05-23
17.48
18.45
17.44
18.19
7,482,400
AAL
2013-05-24
18.11
18.42
17.89
18.21
4,277,800
AAL
2013-05-28
18.44
18.72
18.05
18.12
4,561,900
AAL
2013-05-29
18.06
18.15
17.65
17.83
4,216,200
AAL
2013-05-30
17.92
18.22
17.66
17.67
4,126,600
AAL
2013-05-31
17.66
17.9
17.55
17.57
3,831,500
AAL
2013-06-03
17.54
17.9
17.4
17.73
5,776,800
AAL
2013-06-04
17.78
18.2
17.56
17.65
4,543,800
AAL
2013-06-05
17.15
17.62
16.85
16.95
11,852,000
AAL
2013-06-06
16.92
17.08
15.93
16.64
12,738,600
AAL
2013-06-07
16.89
17.1
16.65
17.02
4,030,900
AAL
2013-06-10
17.09
17.35
17.05
17.26
4,246,400
AAL
2013-06-11
16.94
17.26
16.75
16.92
3,788,700
AAL
2013-06-12
16.97
17.2
16.65
16.88
3,602,200
AAL
2013-06-13
16.85
17.07
16.64
17.01
5,384,700
AAL
2013-06-14
16.96
17.25
16.81
16.93
2,572,500
AAL
2013-06-17
17.02
17.16
16.74
16.95
2,845,000
AAL
2013-06-18
16.94
17.32
16.82
17.22
4,298,600
AAL
2013-06-19
17.16
17.27
17
17.06
2,382,500
AAL
2013-06-20
16.73
17.18
16.53
16.73
5,234,200
AAL
2013-06-21
16.8
16.94
16.05
16.34
6,423,700
AAL
2013-06-24
16.06
16.14
15.59
16.13
6,691,000
AAL
2013-06-25
16.22
16.5
16.16
16.46
3,399,500
AAL
2013-06-26
16.5
16.64
16.17
16.17
3,604,500
AAL
2013-06-27
16.29
16.34
16
16.31
3,566,000
AAL
2013-06-28
16.24
16.55
16.16
16.42
7,063,900
AAL
2013-07-01
16.5
17.04
16.48
16.8
4,666,900
AAL
2013-07-02
16.78
16.79
16.36
16.43
4,009,300
AAL
End of preview. Expand in Data Studio
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

S&P 500 Stock Data - Exploratory Data Analysis

Overview

This project presents an exploratory data analysis (EDA) of daily stock data for S&P 500 companies.
The analysis focuses on sector composition, volatility patterns, and the relationship between risk and return in the S&P 500 universe.

Dataset Description

The analysis combines two public datasets:

  • Price Data: Daily prices (open, high, low, close, volume, symbol) for S&P 500 companies, covering a 5-year period (~620,000 rows).
  • Constituents Data: Sector information for each company, based on the latest S&P 500 constituents list.

The datasets were merged by stock symbol so that each row contains both price history and sector.

Main Research Questions

  1. What percentage of S&P 500 stocks belong to each sector?
  2. Which sector in the S&P 500 is the most volatile?
  3. Within the most volatile sector, which stocks are the most volatile?
  4. Is there a relationship between risk (volatility) and average return for S&P 500 stocks?

Data Cleaning & Preparation

  • Checked and removed duplicate rows.
  • Excluded records with missing or invalid dates, closing prices, or stock symbols.
  • Converted date fields to datetime for accurate time series analysis.
  • Sorted entries by stock and date.
  • Merged sector information from the constituents dataset.
  • Calculated daily returns and stock volatility (standard deviation of daily returns).

Exploratory Analysis & Key Insights

1. Sector Composition

The pie chart shows that Information Technology, Health Care, and Financials are the largest sectors by number of companies, while sectors like Utilities and Materials are less represented in the S&P 500.

Pie Chart of S&P 500 Sectors


2. Sector Volatility

The bar chart reveals that the Energy sector has the highest average volatility among all sectors, indicating that Energy stocks experience the largest daily price fluctuations.

Bar Chart of Sector Volatility


3. Most Volatile Stocks in the Most Volatile Sector

The ranking plot shows that in the Energy sector, WMB (Williams Companies) is the most volatile stock, with a volatility level noticeably higher than all others. DVN and OKE follow, but with lower volatility. The difference between WMB and the rest is especially significant.

Volatility Ranking of Energy Stocks


4. Risk vs. Return

The scatter plot with regression line suggests a weak positive relationship between risk and return: stocks with higher volatility tend to have slightly higher average daily returns, but the overall trend is not strong.

Risk vs Return Scatter Plot


Outlier Handling

Outliers in daily returns were identified using the IQR method. Since these outliers represent actual market events and not errors, they were retained in the analysis.


Limitations

  • Sectoral shares were based on company counts rather than market capitalization, as Market Cap was not available.
  • The analysis did not include dividends, macroeconomic events, or company fundamentals.
  • Results are based on historical price and volume data only.

Conclusion

The EDA uncovers important patterns in sector distribution, volatility, and the risk-return relationship across the S&P 500. It highlights both broad trends and unique behaviors within specific sectors and stocks.


Video Presentation

A link to a short video presentation summarizing these findings will be added here.


Files

  • all_stocks_5yr.csv – Stock price data
  • constituents.csv – Sector/company info
  • sp500_eda.ipynb – Full analysis notebook
  • README.md – This summary

For further details, see the code and visualizations in the attached notebook.

Downloads last month
72