› Forums › Python › Pandas (Python library) › Why `df.shape` is a Property but `df.info()` is a Method in Pandas
- This topic is empty.
-
AuthorPosts
-
January 11, 2026 at 7:20 am #5935
Context
When working with Pandas DataFrames, beginners often notice something curious:
df.shape df.info()Why does one use parentheses and the other doesn’t?
Is this just a style choice, or is there a deeper reason?Let’s break it down in a clean, conceptual way.
Q1. What is the difference between a property and a method in Python?
A property represents something an object has.
A method represents something an object does.Think of a DataFrame like a book:
Book DataFrame Number of pages df.shapePrinting the table of contents df.info()The page count is a fact about the book.
Printing the table of contents is an action.
Q2. Why is
df.shapea property?df.shapereturns:(number_of_rows, number_of_columns)This information is:
- Already stored inside the DataFrame
- Instantly available
- Requires no calculation
- Has no side effects
So Pandas exposes it as a property:
df.shapeYou are simply asking:
“What is your shape?”
Not:
“Please compute something.”
Q3. Why is
df.info()a method?df.info()does a lot of work:It:
- Scans every column
- Counts non-null values
- Detects data types
- Estimates memory usage
- Formats and prints a report
This is a process, not a stored value.
It performs an action, so it is written as a method:df.info()You are saying:
“Run the info routine.”
Q4. Is this just a design choice?
Yes — but a very deliberate one.
Pandas follows this principle:
Use properties for cheap, always-available facts.
Use methods for expensive or procedural operations.That’s why:
Pandas API Type Reason df.shapeProperty Stored metadata df.columnsProperty Already known df.dtypesProperty Already known df.info()Method Needs computation & printing df.describe()Method Needs to scan data df.sum()Method Needs calculation
Q5. Could Pandas have made
infoa property andshapea method?Technically — yes.
Python allows this:
@property def info(self): ...and
def shape(self): ...But that would be bad API design.
Properties should behave like data.
Methods should behave like actions.Imagine this:
x = df.infoIf that suddenly printed output, it would be confusing and dangerous.
Final Takeaway
df.shapeis a property because it is an inherent, instant fact about the DataFrame.df.info()is a method because it is an operation that runs code, scans data, and produces output.This simple design choice makes Pandas feel natural:
- No parentheses → just reading information
- Parentheses → work is being done
That’s why Pandas feels clean, predictable, and Pythonic.
-
AuthorPosts
- You must be logged in to reply to this topic.

