WeCodeAcademy

Reading CSV Data

Real data usually comes from files. pd.read_csv turns CSV text into a DataFrame; df.to_csv() turns it back. In these lessons the "file" is a string wrapped in io.StringIO, because the browser has no files of its own. With a real file you would write pd.read_csv('sales.csv').

Examplepython
Open in editor »
Quick check

What does `pd.read_csv` return?

Your turn: write the code

Read the CSV text and print the total quantity (the sum of the qty column).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.