Documentation Index
Fetch the complete documentation index at: https://ai.tharung.in/llms.txt
Use this file to discover all available pages before exploring further.
What is Pandas?
Pandas is a Python library used for:- Data analysis
- Data cleaning
- Handling tables and CSV files
- Working with structured data easily
- Series → 1D data
- DataFrame → 2D tabular data
Installation
Install Pandas
Importing Pandas
pd is an alias used for shorter syntax.
Series in Pandas
pd.Series()
Creates a one-dimensional labeled array.
Output
Explanation
- Left side → index
- Right side → values
dtype→ datatype of values
Series Attributes
.dtype
Returns datatype of Series values.
Output
Explanation
All values are integers, so datatype isint64.
.values
Returns all values as NumPy array.
Output
Explanation
Converts Series values into NumPy array format..index
Returns indexes of the Series.
Output
Explanation
Indexes start from 0 and end at 4..name
Assigns a name to the Series.
Output
Explanation
The Series now has label"number".
Indexing in Pandas Series
Access Single Value
Output
Explanation
Gets value present at index0.
Slicing
Output
Explanation
Returns values from index0 to 1.End index is excluded.
iloc → Position Based Indexing
Uses numeric positions.
Single Position
Output
Explanation
Returns value at position3.
Multiple Positions
Output
Explanation
Fetches multiple positions together.Custom Index
Output
Explanation
Numeric indexes replaced with custom labels.Label Based Access
Output
Explanation
Returns value associated with label"apple".
loc → Label Based Indexing
Includes both start and end labels.
Output
Explanation
Returns values from"banana" to "orange" inclusive.
Creating Series from Dictionary
Output
Explanation
Dictionary keys become indexes and values become Series values.Conditional Indexing
Filtering Values
Output
Explanation
Returns only values greater than20.
Logical Operators
AND &
Output
Explanation
Both conditions must be true.OR |
Output
Explanation
At least one condition should be true.NOT ~
Output
Explanation
Reverses the condition.Modifying Series
Output
Explanation
Updates value of"apple".
DataFrame in Pandas
pd.DataFrame()
Creates table-like data.
Output
Explanation
Rows and columns together form a DataFrame.head()
Returns first rows.
Output
Explanation
Useful for previewing dataset.tail()
Returns last rows.
Explanation
Shows ending rows of dataset.iloc in DataFrame
Output
Explanation
Selects rows using positions.loc in DataFrame
Output
Explanation
Selects rows and specific columns using labels.drop()
Removes rows or columns.
Explanation
axis=1→ columnaxis=0→ row
.shape
Returns dataset dimensions.
Output
Explanation
4 rows and 4 columns.info()
Shows dataset summary.
Explanation
Displays:- columns
- datatype
- null values
- memory usage
describe()
Shows statistical summary.
Explanation
Provides:- mean
- std
- min
- max
- quartiles
Broadcasting
Applies operation to entire column.Explanation
Adds10000 to every salary value.
rename()
Renames column names.
Explanation
Changes"Name" column to "Employee Name".
unique()
Returns unique values.
Output
Explanation
Removes duplicates and shows distinct values.value_counts()
Counts occurrences of values.
Explanation
Counts frequency of each department.Missing Values
isnull()
Checks missing values.
isnull().sum()
Counts missing values column-wise.
dropna()
Removes missing values.
Explanation
Deletes rows containing null values.fillna()
Fills missing values.
Explanation
Replaces null values with0.
Fill Missing Values with Mean
Explanation
Uses average age to replace null.Forward Fill
Explanation
Uses previous row value.Backward Fill
Explanation
Uses next row value.replace()
Replaces specific values.
Explanation
Changes"Jack" to "Tharun".