Pandas for Fun and Profit: Using Pandas for Successful Investing

Daniel Goldfarb


Pandas is easy and fun to use; even a Python newbie can use it. I tell the story of how, as a new Python developer, I quickly learned enough Pandas to be able test some hypotheses about financial markets. After attending, you too may choose to use Pandas for fun and maybe profit.


During this talk, I tell the story of how, as a new Python developer, I quickly learned enough Pandas to be able test some hypotheses about financial markets. I will demonstrate how I formulated the hypothesis, developed a test plan, gathered data, and tested the hypothesis. Along the way, attendees will see common Pandas techniques for cleaning, converting and reshaping the data, generating new derived data, finding patterns / correlations, and visualizing data. After attending this talk, you may choose to use Pandas to test your own hypotheses for fun (and maybe profit).

The audience for this talk is any level Python developer with little to no experience with Pandas. Through this talk, attendees will learn what Pandas can do, and how it simplifies data analysis. Attendees will also learn how to apply a number of basic Pandas techniques for cleaning data, slicing data, setting and using indices, calculating new columns, merging data sets, generating statistics, and visualizing results.


  • Introduction
  • The Hypothesis
    • Stock ownership and Earnings
    • The Price/Earnings ratio and what it means to analysts
    • Hypothesis: Low P/E represents a “bargain” -- How can we test this?
  • Pandas Basics
    • Series, Data Frame
    • Indexing, loc, iloc, slice
    • Utilities: read_csv, describe, apply, select, sort, transpose, merge, handling missing data
  • Testing Our Hypothesis: Preparing the Data
    • Introduction to the data
    • Cleaning the header; setting the indices
    • Converting Price, P/E, and Dividends
    • Converting Dates
    • Calculating the average and standard deviation of P/E values
    • Merging Dividend Data with the Price and P/E data
  • Testing Our Hypothesis: Calculations and Results
    • Calculating Total Return (for various periods) and generating new columns
    • P/E and Total Return Relationship
  • Conclusions
    • Pandas is fun and easy – even for a newbie.
    • Any data can be analyzed; the art is in gaining an understanding of the data and being creative in your approach to getting valuable information out of the data.


Daniel has been a software engineer at Bloomberg L.P. for nearly three decades. He recently started coding in Python and quickly fell in love with using Pandas for data science.

Daniel has extensive experience developing Trading Systems, Risk Analytics, and applications for analyzing Equities and Fixed Income securities. He has taught numerous engineering courses at Bloomberg. Daniel holds a Ph.D. in Biophysics from the University of Virginia, and was a CFA charter holder and member of the Chartered Financial Analyst Institute for more than 10 years. He is also the author of "Biophysics Demystified."