DataFrame की बुनियादी बातें
एक DataFrame labelled rows और columns वाली एक table है, Python के अंदर एक spreadsheet की तरह।
In this page:
Syntax
df = pd.DataFrame({"column1": [value1, value2],
"column2": [value3, value4]})
DataFrame Basics
एक DataFrame एक two-dimensional labelled structure है जहाँ हर column एक Series है जिसका अपना dtype हो सकता है। यह Pandas का workhorse है। एक बनाने का सबसे simple तरीका columns के एक dictionary से है।
Note:
Columns अलग types hold कर सकते हैं, एक NumPy 2-D array के उलट।
उदाहरण: DataFrame basics
import pandas as pd
df = pd.DataFrame({
"name": ["Ann", "Bob", "Cy"],
"age": [28, 35, 41],
"member": [True, False, True],
})
print(df)
print(df.dtypes)
# Output:
# name age member
# 0 Ann 28 True
# 1 Bob 35 False
# 2 Cy 41 True
# name object
# age int64
# member bool
# dtype: object
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. #}
आम गलतियां
- lists से बनाते वक्त rows और columns confuse करना
- यह उम्मीद करना कि सारे columns एक dtype share करेंगे
- एक copy modify करना और original बदलने की उम्मीद करना
चैप्टर सारांश
- एक DataFrame एक labelled 2-D table है
- Columns Series हैं
- हर column का अपना dtype है
- इसे columns के एक dict से बनाएँ
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: