- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Pandas Data Analysis And Manipulations / of Pandas DataFrame Creation
Introduction to Pandas & Creating a DataFrame
Simple explanation of Pandas, key features, and how to create a DataFrame from list and dictionary data.
1. What is Pandas?
•
Pandas is a Python library used for data analysis and data manipulation.
•
It works mainly with tabular data (rows & columns) similar to Excel tables or SQL tables.
•
Core objects are Series (1D) and DataFrame (2D table).
2. Key Features of Pandas
| Feature | Explanation |
|---|---|
| Easy Data Loading | Read data from CSV, Excel, JSON, SQL, Parquet, HTML, etc. into a DataFrame with a single function call. |
| Data Cleaning | Handle missing values, remove duplicates, convert data types, and fix invalid data. |
| Data Filtering | Filter rows with conditions (for example: age > 21, city == "Hyderabad"). |
| Data Transformation | Add new columns, apply custom functions, merge/join multiple tables, group and aggregate data. |
| Time-Series Support | Strong support for date/time operations like resampling, rolling windows, and date-based indexing. |
| Fast Operations | Internally uses NumPy arrays, so operations are vectorized and much faster than normal Python loops. |
| Easy Export | Export cleaned/processed data back to CSV, Excel, JSON, SQL, etc. using to_* functions. |
3. Creating a DataFrame from a List
•
Use when data is available as a list of rows, each row as a list or tuple.
Step 1: Sample list data
data = [
["John", 25],
["Anna", 30],
["Peter", 35]
]
Step 2: Create DataFrame
import pandas as pd
df_from_list = pd.DataFrame(data, columns=["Name", "Age"])
print(df_from_list)
Output Table
| Name | Age |
|---|---|
| John | 25 |
| Anna | 30 |
| Peter | 35 |
4. Creating a DataFrame from a Dictionary
•
Use when data is available as a dictionary of columns (each key is a column name).
Step 1: Sample dictionary data
data_dict = {
"Name": ["John", "Anna", "Peter"],
"Age": [25, 30, 35]
}
Step 2: Create DataFrame
import pandas as pd
df_from_dict = pd.DataFrame(data_dict)
print(df_from_dict)
Output Table
| Name | Age |
|---|---|
| John | 25 |
| Anna | 30 |
| Peter | 35 |
5. Visual – List vs Dictionary DataFrame
6. Quick Summary
1.
Pandas is used for fast, easy data analysis and manipulation.
2.
Key features: loading, cleaning, filtering, transforming, time-series, and exporting data.
3.
You can create a DataFrame from list data or dictionary data in just one line using
pd.DataFrame().