Souvik Mukherjee
Souvik Mukherjee

Reputation: 55

Specifying absolute directory paths within jupyter

I am still making my way through transitioning into iPython using Jupyter notebooks. All I am trying to do is specify a path name as a string. For subsequent operations, I am importing other packages which seem to have been done correctly. But I can't define the pathname as a string. The code is provided below:


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

file_path = 'C:\Users\shikh\PlayWithPython\Kaggle\titanic\Data'

The error message:

error message

What is the right way to do this? I want to keep my subsequent calls to pd.read_csv and other commands simple and iterable. Any suggestions? Many thanks in advance. Souvik

Upvotes: 2

Views: 132

Answers (1)

Souvik Mukherjee
Souvik Mukherjee

Reputation: 55

Sorry guys ... solved the issue. And I don't need to import os either. Here's the import protocol for anybody else with MATLAB habits switching to Python :)

import pandas as pd 
file_path = 'C:\\Users\\shikh\\PlayWithPython\\Kaggle\\titanic\\Data\\' 
file_name = 'train.csv' 
df_train = pd.read_csv(file_path+file_name) 

Upvotes: 1

Related Questions