Exporting Data

Once you've cleaned, filtered, and shaped your data, the last step is usually getting it back out — into a CSV file others can use, or a quick chart to see what you found.

Writing to CSV

>>> saving a file
import pandas as pd

df = pd.DataFrame({"name": ["Maya", "Sam"], "score": [88, 92]})
df.to_csv("results.csv", index=False)
results.csv
name,score
Maya,88
Sam,92
Note: by default, to_csv() writes the DataFrame's index as an extra unnamed first column in the file — surprising if you weren't expecting it. index=False, used above, skips it and writes only the real columns.

Writing to Excel

The same idea works for spreadsheets, using .to_excel() (this needs the openpyxl package installed alongside pandas):

>>> saving to Excel
df.to_excel("results.xlsx", index=False, sheet_name="Scores")

Same index=False habit applies here too.

A quick look with .plot()

pandas includes basic charting built on matplotlib — enough for a fast sanity check without switching tools, though a real report usually reaches for matplotlib or a dedicated charting library directly:

>>> a bar chart
df.plot(kind="bar", x="name", y="score")

kind="bar" draws a bar chart directly from the DataFrame; other values like "line" or "scatter" cover the other common chart shapes. This only renders in an environment that can display a plot (like Jupyter), not in a plain terminal script.

Course complete: that covers pandas from a bare DataFrame through to real analysis work — creating and reading data, selecting and filtering it with .loc/.iloc, cleaning up missing values, grouping and aggregating, merging multiple sources together, and exporting the results back out. From here, the natural next step is pairing this with the NumPy course or a proper charting library for deeper analysis and visualization.