Bird
Raised Fist0
Data Analysis Pythondata~20 mins

Basic DataFrame info (shape, dtypes, describe) in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
DataFrame Info Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the shape of the DataFrame?
Given the following DataFrame, what will be the output of df.shape?
Data Analysis Python
import pandas as pd

data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'City': ['NY', 'LA', 'SF']}
df = pd.DataFrame(data)
print(df.shape)
A(2, 3)
B(3, 2)
C(3, 3)
D(3, 4)
Attempts:
2 left
💡 Hint
Shape shows (rows, columns). Count rows and columns in the data.
❓ Predict Output
intermediate
2:00remaining
What are the data types of each column?
What will be the output of df.dtypes for this DataFrame?
Data Analysis Python
import pandas as pd

data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30], 'Height': [5.5, 6.0]}
df = pd.DataFrame(data)
print(df.dtypes)
A
Name     int64
Age      object
Height   float64
dtype: object
B
Name     object
Age       int64
Height  float64
dtype: object
C
Name     float64
Age      int64
Height   object
dtype: object
D
Name     object
Age      float64
Height   int64
dtype: object
Attempts:
2 left
💡 Hint
Names are text, ages are whole numbers, heights are decimals.
❓ data_output
advanced
3:00remaining
What does describe() show for numeric columns?
Given this DataFrame, what will df.describe() output?
Data Analysis Python
import pandas as pd

data = {'Score': [80, 90, 100, 70, 85], 'Attempts': [1, 2, 1, 3, 2]}
df = pd.DataFrame(data)
print(df.describe())
A
       Score  Attempts
count    5.0       5.0
mean    85.0       1.8
std      10.0      0.84
min     70.0       1.0
25%     80.0       1.0
50%     85.0       2.0
75%     90.0       2.0
max    100.0       3.0
B
       Score  Attempts
count    5.0       5.0
mean    85.0       1.8
std      11.18     0.84
min     70.0       1.0
25%     75.0       1.0
50%     85.0       2.0
75%     90.0       3.0
max    100.0       3.0
C
       Score  Attempts
count    5.0       5.0
mean    85.0       2.0
std      11.18     1.0
min     70.0       1.0
25%     80.0       1.0
50%     85.0       2.0
75%     90.0       2.0
max    100.0       3.0
D
       Score  Attempts
count    5.0       5.0
mean    85.0       1.8
std      11.18     0.84
min     70.0       1.0
25%     80.0       1.0
50%     85.0       2.0
75%     90.0       2.0
max    100.0       3.0
Attempts:
2 left
💡 Hint
Check the mean and standard deviation carefully.
🧠 Conceptual
advanced
1:30remaining
Which statement about DataFrame dtypes is true?
Consider a DataFrame with columns of different types. Which statement is correct about df.dtypes?
AIt returns a Series showing the data type of each column.
BIt returns the data type of the first column only.
CIt returns a list of all unique data types in the DataFrame.
DIt returns the number of columns for each data type.
Attempts:
2 left
💡 Hint
Think about what you want to know about each column's type.
🔧 Debug
expert
2:30remaining
Why does this describe() call miss some columns?
Given this DataFrame, why does df.describe() only show one column?
Data Analysis Python
import pandas as pd
import numpy as np

data = {'A': [1, 2, 3], 'B': ['x', 'y', 'z'], 'C': [np.nan, np.nan, np.nan]}
df = pd.DataFrame(data)
print(df.describe())
Adescribe() by default only summarizes numeric columns, so only column 'A' appears.
Bdescribe() fails because column 'C' has NaN values and stops processing.
Cdescribe() only shows columns with no missing values, so 'C' is excluded.
Ddescribe() shows all columns but output is truncated to one column by default.
Attempts:
2 left
💡 Hint
Check pandas describe default behavior with non-numeric columns.

Practice

(1/5)
1. What does df.shape tell you about a DataFrame?
easy
A. The data types of each column
B. The number of rows and columns in the DataFrame
C. Summary statistics like mean and median
D. The first few rows of the DataFrame

Solution

  1. Step 1: Understand what df.shape returns

    df.shape gives a tuple with two numbers: rows and columns count.
  2. Step 2: Match the description to the options

    The number of rows and columns in the DataFrame correctly describes this as the number of rows and columns.
  3. Final Answer:

    The number of rows and columns in the DataFrame -> Option B
  4. Quick Check:

    Shape = (rows, columns) [OK]
Hint: Remember shape shows size: rows and columns [OK]
Common Mistakes:
  • Confusing shape with data types
  • Thinking shape shows data summary
  • Mixing shape with head() output
2. Which of the following is the correct way to check the data types of columns in a DataFrame named df?
easy
A. df.dtypes
B. df.columns.types
C. df.describe()
D. df.types()

Solution

  1. Step 1: Recall the attribute for column data types

    The correct attribute to check data types is df.dtypes, not a method.
  2. Step 2: Verify the options

    df.dtypes uses df.dtypes correctly. Others are invalid or do not exist.
  3. Final Answer:

    df.dtypes -> Option A
  4. Quick Check:

    dtypes attribute shows column types [OK]
Hint: Use df.dtypes without parentheses to check types [OK]
Common Mistakes:
  • Adding parentheses like df.dtypes()
  • Using non-existent methods like df.types()
  • Confusing describe() with dtypes
3. Given the DataFrame 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())

What will be the output of df.describe()?
medium
A. Summary statistics for all columns including C
B. An error because column C is non-numeric
C. Summary statistics for columns A and B only, excluding C
D. Only the count of rows

Solution

  1. Step 1: Understand what df.describe() does

    It provides summary stats (count, mean, std, min, max, quartiles) for numeric columns only by default.
  2. Step 2: Check the DataFrame columns

    Columns A and B are numeric (int and float), C is string (non-numeric), so C is excluded.
  3. Final Answer:

    Summary statistics for columns A and B only, excluding C -> Option C
  4. Quick Check:

    describe() skips non-numeric columns by default [OK]
Hint: describe() shows stats only for numeric columns by default [OK]
Common Mistakes:
  • Expecting describe() to include string columns
  • Thinking describe() throws error on strings
  • Assuming describe() shows only count
4. You run the code below and get an error:
import pandas as pd
data = {'X': [10, 20, 30], 'Y': [5, 15, 25]}
df = pd.DataFrame(data)
print(df.dtypes())

What is the cause of the error?
medium
A. dtypes is an attribute, not a method, so parentheses cause error
B. DataFrame columns have mixed types
C. DataFrame is empty
D. Missing import statement for pandas

Solution

  1. Step 1: Identify the error source

    The code calls df.dtypes() with parentheses, but dtypes is an attribute, not a method.
  2. Step 2: Understand correct usage

    Correct usage is df.dtypes without parentheses to access data types.
  3. Final Answer:

    dtypes is an attribute, not a method, so parentheses cause error -> Option A
  4. Quick Check:

    Use df.dtypes without () [OK]
Hint: Remember dtypes is attribute, no parentheses [OK]
Common Mistakes:
  • Adding parentheses to dtypes
  • Assuming error is from missing import
  • Thinking DataFrame is empty
5. You have a DataFrame 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?
hard
A. df.columns; df.dtypes; df.tail()
B. df.describe(); df.shape; df.columns
C. df.info(); df.head(); df.describe()
D. df.shape; df.dtypes; df.describe()

Solution

  1. Step 1: Identify commands for each info type

    df.shape gives rows and columns count, df.dtypes shows data types, and df.describe() gives summary stats for numeric columns.
  2. Step 2: Check options for correct sequence

    df.shape; df.dtypes; df.describe() lists these three commands in order, so it provides all required info.
  3. Final Answer:

    df.shape; df.dtypes; df.describe() -> Option D
  4. Quick Check:

    shape, dtypes, describe cover size, types, stats [OK]
Hint: Use shape, dtypes, then describe for full quick info [OK]
Common Mistakes:
  • Using df.columns instead of df.dtypes for types
  • Confusing df.info() with df.describe()
  • Missing shape to check size
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard