5. pandas DataFrames and Series
5.2 head, info, dtypes
Steps in Jupyter
- Run the DataFrame code above.
df.head()— first 5 rows (here all 3).df.shape—(3, 7)means 3 rows, 7 columns.df.info()— non-null counts and dtypes.df.dtypes— column types only.df.describe()— numeric summary (qty, amount).df["city"]ordf.city— one Series.
What you should see. amount and qty as int64; text columns as object (string). Cancelled row still appears — filtering comes in Chapter 6.
Ravindra Bagale's Tip
The short form df.city works only when the column name is a simple word. If the name has a space, like order id, the dot form breaks, so use square brackets: df["order id"]. A good habit is to rename such columns to names like order_id right after you load the file.
Ravindra Bagale's Tip – मराठी
df.city हा छोटा प्रकार फक्त column चं नाव साधा एक शब्द असेल तेव्हाच चालतो. नावात space असेल, जसं order id, तर dot पद्धत चालत नाही, म्हणून square brackets वापरा: df["order id"]. File load केल्यावर लगेच अशा columns ची नावं order_id सारखी ठेवणं ही चांगली सवय आहे.
Ravindra Bagale's Tip – हिंदी
df.city वाला छोटा तरीक़ा तभी चलता है जब column का नाम एक सीधा शब्द हो। नाम में space हो, जैसे order id, तो dot वाला तरीक़ा काम नहीं करता, इसलिए square brackets लगाओ: df["order id"]। File load करते ही ऐसे columns के नाम order_id जैसे रख देना एक अच्छी आदत है।