From the course: Testing Python Data Science Code
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
pandas utilities - Python Tutorial
From the course: Testing Python Data Science Code
pandas utilities
- [Instructor] Hypothesis provides several utilities to generate Pandas objects, such as data frames, columns, indexes and more. You can look at the documentation and see we have indexes, range indexes, series, columns, data frames and more. To show you how it's done, let's work a little bit with some stock information. So here's our function that we would like to test. It calculates the max drop or difference of a stock throughout the day. So we create a copy of the data frame, calculate the diff between the high and the low of the day, and then do a groupby by the diff with the max value. And here is our test. We do the usual imports from hypothesis but also include column and data frames from hypothesis extras Pandas, and then here's a strategy. We want a data frames which have the following columns. And it's enough to put only the columns that we are using in our function. So we have a symbol and we say that we want…