Need to **load and analyze CSV files** in Jupyter Notebook? In this tutorial, we’ll walk you through different methods to **import CSV files into Jupyter Notebook** using Python. Whether you're working on **data science, machine learning, or data analysis**, handling CSV files is an essential skill.
By the end of this video, you’ll be able to **read, explore, and manipulate CSV files** in Jupyter Notebook like a pro!
### **What You’ll Learn in This Video:**
How to open Jupyter Notebook and set up your environment
Methods to **import a CSV file** into Jupyter Notebook
Using **Pandas** to load and manipulate CSV data
Handling CSV file paths (relative & absolute paths)
Dealing with **missing values and data types**
Saving and exporting CSV files after processing
Common errors when loading CSVs and how to fix them
---
### ** Step-by-Step Guide to Importing CSV in Jupyter Notebook**
#### **1⃣ Install Pandas (If Not Installed)**
First, ensure you have **pandas** installed in your Python environment. If not, install it using:
```bash
pip install pandas
```
#### **2⃣ Open Jupyter Notebook**
To launch Jupyter Notebook, run the following command in your terminal or command prompt:
```bash
jupyter notebook
```
#### **3⃣ Import Required Libraries**
```python
import pandas as pd
```
#### **4⃣ Load a CSV File from the Same Directory**
If your CSV file is in the **same directory** as your Jupyter Notebook, use:
```python
df = pd.read_csv("data.csv")
print(df.head()) # Display the first 5 rows
```
#### **5⃣ Load a CSV File from a Different Directory**
Use an **absolute path** if your file is stored elsewhere:
```python
df = pd.read_csv("C:/Users/YourName/Documents/data.csv") # Windows
df = pd.read_csv("/home/username/documents/data.csv") # Mac/Linux
```
#### **6⃣ Handling Missing Values & Data Types**
```python
df.info() # Check data types and missing values
df.fillna(0, inplace=True) # Replace missing values with 0
df["column_name"] = df["column_name"].astype(float) # Convert data type
```
#### **7⃣ Saving Processed Data to a New CSV File**
```python
df.to_csv("cleaned_data.csv", index=False)
```
---
### ** Useful Links:**
Pandas Documentation: [https://pandas.pydata.org/docs/](https://pandas.pydata.org/docs/)
Jupyter Notebook Guide: [https://jupyter.org/](https://jupyter.org/)
**Have Questions?** Drop a comment below! If you found this tutorial helpful, **LIKE** this video, **SUBSCRIBE** for more Python and Jupyter Notebook tutorials, and **SHARE** with your friends!
**Hashtags:**
#Python #JupyterNotebook #DataScience #Pandas #CSVFiles #PythonDataAnalysis #MachineLearning #PythonTutorial #DataAnalytics #JupyterTips