DataFrame in Python
A DataFrame is a dict of Series that share one index.
import pandas as pd
frame = pd.DataFrame({
"lang": ["python", "rust", "sql"],
"tours": [11, 12, 3],
"tpm": [104.5, 98.0, 88.5],
})
print(frame.shape, list(frame.columns))
print(frame.dtypes)
print(frame.head(2))
print(frame.describe().round(2))
How it works
- Building from a dict makes each key a column.
shape,columnsanddtypesdescribe it.headis how you look without printing everything.
Keywords and builtins used here
aslistprint
The run, in numbers
- Lines
- 12
- Characters to type
- 246
- Tokens
- 96
- Three-star pace
- 100 tpm
At the three-star pace of 100 tokens a minute, this run takes about 58 seconds.
Step 2 of 4 in Series & frames, step 2 of 26 in pandas.