Skip to Content
Functional Python Programming - Second Edition
book

Functional Python Programming - Second Edition

by Steven F. Lott
April 2018
Intermediate to advanced content levelIntermediate to advanced
408 pages
10h 42m
English
Packt Publishing
Content preview from Functional Python Programming - Second Edition

Getting raw data

The raw_data() function is similar to the example shown in Chapter 3, Functions, Iterators, and Generators. We included some important changes. Here's what we're using for this application:

from Chapter_3.ch03_ex5 import (    series, head_map_filter, row_iter)from typing import (    NamedTuple, Callable, List, Tuple, Iterable, Dict, Any)RawPairIter = Iterable[Tuple[float, float]]class Pair(NamedTuple):    x: float    y: floatpairs: Callable[[RawPairIter], List[Pair]] \     = lambda source: list(Pair(*row) for row in source)def raw_data() -> Dict[str, List[Pair]]:    with open("Anscombe.txt") as source:        data = tuple(head_map_filter(row_iter(source)))        mapping = {            id_str: pairs(series(id_num, data))            for id_num, id_str in enumerate( ['I', 'II', ...
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

Functional Python Programming - Third Edition

Functional Python Programming - Third Edition

Steven F. Lott

Publisher Resources

ISBN: 9781788627061Supplemental Content