Data Wrangling for Fundamental Stock Analysis

4 min readSep 5, 2021

Gather data and perform fundamental analysis for a market.

Photo by Chris Liverani on Unsplash


In this article, let’s use our coding skills to evaluate and choose quality stocks. It is fun to collate stock data for a particular market and perform fundamental analyses.

Getting Stock Market Data

I am going to use the investpy library to gather market information.

Let’s get started!

Getting Stocks for a Market
  • investpy library is a Python library that can be used to scrape market data. In this example, I download a list of US stocks.
Stocks Information
  • As you can see, there are 4,582 stocks, and efforts to manually select the stocks are going to be tremendous. Let’s see what we can do to shortlist some stocks.
  • The dataset is saved to a CSV file for later use.

Choosing the Metrics

There are many metrics that can be used to select good stocks. To make it simple, I am going to use the price-to-earnings (P/E) ratio and dividend history.

Stock Information

Let’s get the financial information for each stock using investpy.

Getting Stock Information
Stocks Financial Information

Now I have basic financial information like EPS, P/E ratio, market capital, revenue, beta, next earnings date, etc for each stock.

Dividend History

Let’s download the dividend history for the stocks.


Software engineer, Data Science and ML practitioner.