0Pricing
Data Science Academy · บทเรียน

บันทึกผลลัพธ์เป็น CSV และ Excel

ส่งออกการวิเคราะห์เพื่อแบ่งปัน

บันทึกผลลัพธ์เป็น CSV และ Excel เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

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. 🎉

คำถามที่พบบ่อย

บทเรียน “บันทึกผลลัพธ์เป็น CSV และ Excel” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “บันทึกผลลัพธ์เป็น CSV และ Excel” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “บันทึกผลลัพธ์เป็น CSV และ Excel”

ส่งออกการวิเคราะห์เพื่อแบ่งปัน คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “บันทึกผลลัพธ์เป็น CSV และ Excel” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม

ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. read_csv และตัวเลือกที่มีประโยชน์
  2. เปิดชีต Excel ใน pandas
  3. แยกวิเคราะห์วันที่และกำหนด dtypes ขณะโหลด
  4. บันทึกผลลัพธ์เป็น CSV และ Excel
← กลับไปที่ Data Science Academy