top of page

Python - Securities Analysis

  • Writer: Eighplus Admin
    Eighplus Admin
  • Apr 5, 2022
  • 2 min read

Updated: Apr 27, 2025


Let's explore Funtern's master securities data sample.


1. Import the data

2. Conduct descriptive analysis. How many ticker ids are there?

3. Do a chart to show how many stock quarters have earnings with positive surprise/negative surprise/no surprise

  • if earnings.EPSSurpriseDollar >0, there is a positive surprise

  • if earnings.EPSSurpriseDollar < 0, there is a negative surprise

  • if earnings.EPSSurpriseDollar = 0, there is no surprise

4. Draw a histogram on earnings.numberOfEstimates. Find the average and the mode. Is the distribution skewed?


1. Import the data

We use Python to do this project.

In this project, we import pandas and numpy, since we need to draw a bar chart and a histogram, we import matplotlib and pyecharts. Since this file is “csv”, so when we input it, we write “=pd.read_csv”, the following content is the file’s path.





2. Conduct descriptive analysis, how many ticker ids are there?

We can notice that there are a lot of non available data when we use “describe” to check specific information. So we use “drop” to delete these non available data. We delete non available data based on “earnings.earnings.actualEPS” as this column is what we can get in reality. After deleting non available data, there are 11823 rows left. So there are 11823 ticker ids.




3. Do a chart to show how many stock quarters have earnings with positive surprise/negative surprise/no surprise

To solve this question, first we need to create a new column named “surprise_condition” to represent “positive surprise”, “negative surprise” and “no surprise”. Since there are many unrelated data, we extract the key columns “.id” and ”earnings.earnings.EPSSurpriseDollar” out, and we name this new file as “data1”. We use “where” function to create column “surprise_condition”. The codes are shown as below.








Of course we need to delete non available data based on “earnings.earnings.EPSSurpriseDollar”. Then we use pivot table to create a frequency chart.







According to this chart, we can draw a bar chart. And we can see there is no “no surprise”, which means there is no data in column “earnings.EPSSurpriseDollar” is equal to 0.



4.Draw a histogram on earnings.numberOfEstimates. Find the average and the mode. Is the distribution skewed?

We extract “earnings.earnings.fiscalPeriod” and “earnings.earnings.numberOfEstimates” out to create a new chart named “data2”.



After deleting non available data, we can get the mean is 4.412914 and the mode is 1.0.







We use “plot” to draw a histogram and its density map to show its data distribution. From these two charts, we can know that this distribution is right skewed.






And we also can calculate its skewed value, 1.531848, which is larger than 0, so this distribution is right skewed.


FUNTERN Associate: Jin Wang

Comments


bottom of page