Concept Flow - Basic DataFrame info (shape, dtypes, describe)
Create DataFrame
Check shape
Check dtypes
Run describe()
Review summary statistics
Start with a DataFrame, then check its size, data types, and summary statistics step-by-step.
import pandas as pd data = {'Age': [25, 30, 22], 'Name': ['Ann', 'Bob', 'Cal'], 'Score': [88.5, 92.0, 85.0]} df = pd.DataFrame(data) print(df.shape) print(df.dtypes) print(df.describe())
| Step | Action | Output Type | Output Value |
|---|---|---|---|
| 1 | Create DataFrame from dictionary | DataFrame | {'Age': [25,30,22], 'Name': ['Ann','Bob','Cal'], 'Score': [88.5,92.0,85.0]} |
| 2 | Check shape | tuple | (3, 3) |
| 3 | Check dtypes | Series | Age int64 Name object Score float64 dtype: object |
| 4 | Run describe() | DataFrame | Age Score count 3.000000 3.000000 mean 25.666667 88.500000 std 4.041452 3.511885 min 22.000000 85.000000 25% 23.500000 86.250000 50% 25.000000 88.500000 75% 27.500000 90.250000 max 30.000000 92.000000 |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 |
|---|---|---|---|---|---|
| df | None | DataFrame with 3 rows and 3 columns | Same | Same | Same |
| shape | None | None | (3, 3) | (3, 3) | (3, 3) |
| dtypes | None | None | None | Age int64, Name object, Score float64 | Age int64, Name object, Score float64 |
| describe | None | None | None | None | Summary stats DataFrame for numeric columns |
Basic DataFrame info: - df.shape shows rows and columns count - df.dtypes shows data type per column - df.describe() summarizes numeric columns Use these to quickly understand your data size and types.
df.shape tell you about a DataFrame?df.shape returnsdf.shape gives a tuple with two numbers: rows and columns count.df?df.dtypes, not a method.df.dtypes correctly. Others are invalid or do not exist.df below:import pandas as pd
data = {'A': [1, 2, 3], 'B': [4.0, 5.5, 6.1], 'C': ['x', 'y', 'z']}
df = pd.DataFrame(data)
print(df.describe())df.describe()?df.describe() doesimport pandas as pd
data = {'X': [10, 20, 30], 'Y': [5, 15, 25]}
df = pd.DataFrame(data)
print(df.dtypes())df.dtypes() with parentheses, but dtypes is an attribute, not a method.df.dtypes without parentheses to access data types.df with columns: Age (int), Salary (float), and Department (string). You want to quickly check how many rows and columns it has, the data types of each column, and summary statistics for numeric columns. Which sequence of commands gives you all this information?df.shape gives rows and columns count, df.dtypes shows data types, and df.describe() gives summary stats for numeric columns.df.shape; df.dtypes; df.describe() lists these three commands in order, so it provides all required info.Pass the test and this pattern moves unknown