← Back to Pandas Course | Chapter 3: DataFrame Basics | Lesson 2 of 7

DataFrame के Attributes (shape/dtypes/columns)

Attributes आपको बिना सब कुछ print किए एक DataFrame का size, column names, और data types बताते हैं।
Syntax
python
df.shape
df.dtypes
df.columns
df.index

DataFrame Attributes (shape/dtypes/columns)

shape (rows, columns) देता है, columns column labels list करता है, index row labels दिखाता है, और dtypes हर column का type report करता है। ये attributes हैं, methods नहीं, इसलिए कोई parentheses नहीं। values underlying NumPy array return करता है।

Note: len(df) rows की संख्या return करता है।

उदाहरण: DataFrame attributes (shape/dtypes/columns)

python
import pandas as pd

df = pd.DataFrame({"name": ["Ann", "Bob"], "age": [28, 35], "score": [88.5, 92.0]})
print(df.shape)
print(list(df.columns))
print(df.dtypes)
print(len(df))

# Output:
# (2, 3)
# ['name', 'age', 'score']
# name      object
# age        int64
# score    float64
# dtype: object
# 2
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. shape() को एक function की तरह call करना
  2. यह भूल जाना कि dtypes plural है
  3. len(df) को columns की संख्या से confuse करना
चैप्टर सारांश
  • shape (rows, cols) है
  • columns labels list करता है
  • dtypes types दिखाता है
  • ये attributes हैं methods नहीं
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.