Skip to Content
Data Science da zero, seconda edizione
book

Data Science da zero, seconda edizione

by Joel Grus
April 2025
Intermediate to advanced
406 pages
9h 41m
Italian
O'Reilly Media, Inc.
Content preview from Data Science da zero, seconda edizione

Capitolo 9. Ottenere i dati

Questo lavoro è stato tradotto utilizzando l'AI. Siamo lieti di ricevere il tuo feedback e i tuoi commenti: translation-feedback@oreilly.com

Per scriverlo ci sono voluti tre mesi; per concepirlo, tre minuti; per raccogliere i dati in esso contenuti, tutta la mia vita.

F. Scott Fitzgerald

Per essere uno scienziato dei dati hai bisogno di dati. In effetti, come scienziato dei dati passerai una parte imbarazzante del tuo tempo ad acquisire, pulire e trasformare i dati. In caso di necessità, puoi sempre digitare tu stesso i dati (o se hai dei tirapiedi, farli fare a loro), ma di solito questo non è un buon uso del tuo tempo. In questo capitolo vedremo diversi modi per inserire i dati in Python e nei formati giusti.

stdin e stdout

Se esegui i tuoi script Python dalla riga di comando, puoi inviare i dati attraverso di essi utilizzando sys.stdin e sys.stdout. Ad esempio, ecco uno script che legge le righe di testo e le restituisce in base a un'espressione regolare:

# egrep.py
import sys, re

# sys.argv is the list of command-line arguments
# sys.argv[0] is the name of the program itself
# sys.argv[1] will be the regex specified at the command line
regex = sys.argv[1]

# for every line passed into the script
for line in sys.stdin:
    # if it matches the regex, write it to stdout
    if re.search(regex, line):
        sys.stdout.write(line)

Ed eccone uno che conta le righe che riceve e poi scrive il conteggio:

# line_count.py
import sys

count = 0
for line in sys.stdin:
    count ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Elaborazione AI e montaggio automatico per video in tempo reale

Elaborazione AI e montaggio automatico per video in tempo reale

Pauli Olavi Ojala
Cos'è la legge UE sull'IA?

Cos'è la legge UE sull'IA?

Larysa Visengeriyeva

Publisher Resources

ISBN: 9798341643666