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.
Challenge: Testing numerical code - Python Tutorial
From the course: Testing Python Data Science Code
Challenge: Testing numerical code
(upbeat electronic music) - [Instructor] In this challenge, you have some metric data in a JSON line file, meaning every line in the file is a JSON object. We have the time, the metric, which is going to be memory or CPU, and the value. And you have the code for loading the metrics. Using pandas with JSON with the JSON file, says the orientation is for records. The lines are true meaning it's one JSON object per line and we tell pandas to convert the dates in the time field because JSON does not have a time data type. And for testing, here is a main where we have from pathlib import path. We get the absolute path to the file and we load it. What I'd like you to do is write a Pandera schema for the metrics and add a check output decorator to load metrics.
Contents
-
-
-
-
-
-
Using schemas2m 51s
-
(Locked)
Truth values2m 35s
-
(Locked)
Floating point wonders1m 46s
-
(Locked)
Approximate testing1m 18s
-
(Locked)
Dealing with randomness1m 45s
-
(Locked)
Comparing pandas DataFrames1m 31s
-
(Locked)
Challenge: Testing numerical code56s
-
(Locked)
Solution: Testing numerical code51s
-
-
-
-