You can import your custom dataset into Jupyter Notebook using various methods, depending on the file format and your preferred library.
1. Using Pandas:
-
For CSV files:
import pandas as pd # Load the CSV file into a Pandas DataFrame data = pd.read_csv('your_dataset.csv') # View the DataFrame print(data.head())
-
For Excel files:
import pandas as pd # Load the Excel file into a Pandas DataFrame data = pd.read_excel('your_dataset.xlsx') # View the DataFrame print(data.head())
2. Using NumPy:
-
For text files:
import numpy as np # Load the text file into a NumPy array data = np.loadtxt('your_dataset.txt', delimiter=',') # View the array print(data)
3. Using Python's built-in functions:
-
For text files:
# Open the text file with open('your_dataset.txt', 'r') as file: # Read the file line by line data = file.readlines() # View the data print(data)
Remember to replace 'your_dataset.csv'
, 'your_dataset.xlsx'
, 'your_dataset.txt'
with the actual path to your dataset file.