Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Connecting the dots

So far, we've created just one task. Even on its own, it has some value, as it formalizes the work and the output. Now, let's add tasks to collect data for battle. It will look very similar to the previous one—we create a task, inheriting from the Task class:

# luigi_battles.pyfrom misc import _parse_in_depthfrom luigi_fronts import ParseFrontsclass ParseFront(luigi.Task):    front = luigi.Parameter()    def requires(self):        return ScrapeFronts()         def output(self):        path = str(folder / 'fronts' / (self.front + '.json'))        return luigi.LocalTarget(path)     def run(self):        with open(self.input().path, 'r') as f:            fronts = json.load(f)        front = fronts[self.front]        result = {}        for cp_name, campaign in front.items(): result[cp_name] = _parse_in_depth(campaign, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content