A DataFrame is a 2-D table: a collection of Series columns sharing one index. It's the object you'll use almost all the time — rows are records, columns are fields, each column has its own dtype.
Creating a DataFrame
df = pd.DataFrame({"name": ["Aanya", "Rohan", "Priya"],"programme": ["Data", "Full Stack", "Data"],"package": [6.5, 8.0, 7.25],})df
Anatomy
- index — the row labels (0, 1, 2… by default).
- columns — the named fields, each a Series with its own dtype.
- values — the underlying 2-D NumPy data.
df.index # the row labelsdf.columns # Index(['name', 'programme', 'package'])df["package"] # one column → a Seriesdf.dtypes # the type of each column
Key takeaways
- 01A DataFrame is a 2-D labelled table: columns (Series) sharing one index.
- 02Rows are records, columns are named fields, each column has its own dtype.
- 03Access parts via .index, .columns, .dtypes and df["col"].
- 04Most operations return a new DataFrame — chain them; the original is unchanged.
