Pandas DataFrame Initialization and Summary

import pandas as pd data= {     'Name' : ['dhananjay','preeti', 'shambhu'],     'age' : [50,40,15],     'DOB' : [10,30,24] } df=pd.DataFrame(data) This code snippet initializes a small dataset and displays its structural summary using the #Python #pandas library. Step-by-Step Code Explanation import pandas as pd: Imports the pandas library and assigns it the alias pd, which is the standard convention for accessing its functions. data = { ... }: Creates a Python #dictionary where keys represent column headers ('Name', 'age', 'DOB') and values are lists of data points associated with those headers. df = pd.DataFrame(data): Converts the dictionary into a DataFrame object—a two-dimensional, table-like structure—and assigns it to the variable df. df.info(): Executes a method that prints a concise technical summary of the DataFrame structure directly to the console. --------------------------------------- Understanding the Output Window When we run df.info(), the output provides a metadata report for our table: <class 'pandas.core.frame.DataFrame'>: Confirms that our variable df is indeed a Pandas DataFrame object. RangeIndex: Shows the index of the rows (0 to 2, indicating 3 total rows). Data columns: Lists the columns by name and displays: Non-Null Count: Indicates that all 3 rows have valid data (no missing or NaN values). Dtype: Shows the data type for each column; 'Name' will likely be object (text), while 'age' and 'DOB' will be int64 (integers). dtypes & memory usage: Summarizes the count of different data types used and estimates the amount of RAM the DataFrame is occupying. SkillCourse CoDing SeeKho

  • text

To view or add a comment, sign in

Explore content categories