DataFrame के Attributes (shape/dtypes/columns)
Attributes आपको बिना सब कुछ print किए एक DataFrame का size, column names, और data types बताते हैं।
In this page:
Syntax
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)
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. #}
आम गलतियां
- shape() को एक function की तरह call करना
- यह भूल जाना कि dtypes plural है
- 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: