Read a .csv into pandas from F: drive on Windows 7

后端 未结 6 1101
广开言路
广开言路 2020-12-19 02:04

I have a .csv file on my F: drive on Windows 7 64-bit that I\'d like to read into pandas and manipulate.

None of the examples I see read from anything other than a s

6条回答
  •  醉梦人生
    2020-12-19 02:48

    I cannot promise that this will work, but it's worth a shot:

    import pandas as pd
    import os
    
    trainFile = "F:/Projects/Python/coursera/intro-to-data-science/kaggle/data/train.csv"
    
    pwd = os.getcwd()
    os.chdir(os.path.dirname(trainFile))
    trainData = pd.read_csv(os.path.basename(trainFile))
    os.chdir(pwd)
    

提交回复
热议问题