Why doesn't DataFrame.shape have parentheses?

Quick Overview

Asks why pandas DataFrame.shape is written without parentheses while methods like head() need them. Tests whether you understand Python attributes, properties and methods, what shape returns, and the pandas convention that separates cheap descriptors from operations.

Why doesn't DataFrame.shape have parentheses?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

Why doesn't `DataFrame.shape` have parentheses? You call `df.head()` and `df.describe()` with parentheses, but you read `df.shape` without them. ```hint Look at what comes back Check the type of `df.shape`, then ask what Python does when you put parentheses after a value of that type. ``` ### What a Strong Answer Covers - The difference between an attribute (including a property) and a method in Python - What `df.shape` returns and what happens if you call it - How a Python `property` lets a value be computed on access while being read without parentheses - The pandas convention for which members are properties and which are methods, with examples ### Follow-up Questions - What does `df.head` without parentheses return, and why does it not raise an error? - Why does `if df.empty():` raise a TypeError? - What is the difference between `df.size`, `len(df)` and `df.count()`? - NumPy lets you assign `arr.shape = (3, 4)`. What happens if you try `df.shape = (3, 4)` in pandas?

Overview: Asks why pandas DataFrame.shape is written without parentheses while methods like head() need them. Tests whether you understand Python attributes, properties and methods, what shape returns, and the pandas convention that separates cheap descriptors from operations.

General logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

Why doesn't DataFrame.shape have parentheses?

You call df.head() and df.describe() with parentheses, but you read df.shape without them.

What a Strong Answer Covers Guidance

  • The difference between an attribute (including a property) and a method in Python
  • What df.shape returns and what happens if you call it
  • How a Python property lets a value be computed on access while being read without parentheses
  • The pandas convention for which members are properties and which are methods, with examples

Follow-up Questions Guidance

  • What does df.head without parentheses return, and why does it not raise an error?
  • Why does if df.empty(): raise a TypeError?
  • What is the difference between df.size , len(df) and df.count() ?
  • NumPy lets you assign arr.shape = (3, 4) . What happens if you try df.shape = (3, 4) in pandas?