Salvare i risultati in CSV ed Excel
Esportare l'analisi per condividerla.
Salvare i risultati in CSV ed Excel è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Data Science Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Data Science Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Analysis Has to Travel
Your cleaned table is only useful if others can open it. The last step of most projects is writing results back out to a file. 📤
Write a CSV in One Line
Save any DataFrame to disk with to_csv. Pass a filename and pandas writes every row and column for you.
df.to_csv("clean_sales.csv")Drop the Extra Index
By default to_csv writes the row index as a first column. Pass index=False when that numbering is just noise.
df.to_csv("clean_sales.csv", index=False)Match the Reader's Locale
If colleagues open CSVs in European Excel, set sep to a semicolon so columns line up instead of cramming into one.
df.to_csv("out.csv", sep=";", index=False)Keep Text Safe
For names with accents or symbols, write with encoding="utf-8" so nothing turns into garbled characters on the other side.
df.to_csv("names.csv", encoding="utf-8")Save to Excel Too
Prefer a spreadsheet? to_excel writes an xlsx file, ready to open in Excel, Numbers, or Google Sheets.
df.to_excel("clean_sales.xlsx", index=False)Name the Sheet
The sheet_name option labels the tab inside your workbook, so the file is self-explanatory the moment it opens.
df.to_excel("report.xlsx",
sheet_name="Summary", index=False)Many Tables, One Workbook
Use an ExcelWriter to place several DataFrames on different tabs of a single shareable file.
with pd.ExcelWriter("book.xlsx") as w:
df1.to_excel(w, sheet_name="raw")
df2.to_excel(w, sheet_name="summary")Pick Just Some Columns
Export only what matters by passing columns with the list you want. The rest stay out of the saved file.
df.to_csv("slim.csv",
columns=["date", "total"], index=False)Round-Trip Friendly
A file you save with to_csv can be reopened later with read_csv, closing the loop from raw input to polished output.
Pick the Right Format
Choose CSV for size and portability, Excel for formatting and multiple sheets. Match the file to who opens it next.
Quick Check
You are exporting a CSV and do not want the row numbers saved. What do you set?
Recap: Ship Your Results
You can now export with to_csv and to_excel: drop the index, set separators and encoding, name sheets, and pick columns. The loop is complete. 🎉
Domande Frequenti
La lezione «Salvare i risultati in CSV ed Excel» è gratuita?
Sì — il testo completo di «Salvare i risultati in CSV ed Excel» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Data Science Academy, passa a CoddyKit PRO. Il corso Data Science Academy include 4 lezioni in totale.
Cosa imparerò in «Salvare i risultati in CSV ed Excel»?
Esportare l'analisi per condividerla. Eserciti Data Science Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Data Science Academy?
Non è richiesta alcuna esperienza precedente. Data Science Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Salvare i risultati in CSV ed Excel»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Data Science Academy?
Sì. Ogni lezione Data Science Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- read_csv e le sue opzioni utili
- Aprire fogli Excel in pandas
- Analizzare le date e impostare i dtypes al caricamento
- Salvare i risultati in CSV ed Excel