简体   繁体   中英

IPython Anaconda PyCharm Windows 8.1 Issue

I was running this code

import pandas as pd
import numpy as np
import glob
import csv
import os
import sys

##Combine all student CSVs from NWEA into one CSV with export
##from http://stackoverflow.com/questions/20906474/import-multiple-csv-files-into-python-pandas-and-concatenate-into-one-dataframe
path = r'NWEA CSVs/Raw/*'
allFiles = glob.glob(path + "/StudentsBySchool.csv")
Sframe = pd.DataFrame()
SframeDup = pd.DataFrame()
list = []
for file in allFiles:
    sdf = pd.read_csv(file,index_col=None, header=0)
    list.append(sdf)
Sframe = pd.concat(list,ignore_index=False)

in IPython 2.3.1 in Ubunto 14.04 and it worked just fine. I then installed PyCharm with Anaconda 3 and IPython on Windows 8.1, ran the exact same code, and encountered the following errors:

Traceback (most recent call last):
  File "C:\Users\mikeronni\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-11-184a20117d62>", line 18, in <module>
    Sframe = pd.concat(list,ignore_index=False)
  File "C:\Users\mikeronni\Anaconda3\lib\site-packages\pandas\tools\merge.py", line 724, in concat
    copy=copy)
  File "C:\Users\mikeronni\Anaconda3\lib\site-packages\pandas\tools\merge.py", line 769, in __init__
    raise ValueError('All objects passed were None')
ValueError: All objects passed were None

I have tried installing the newest versions of pandas and IPython, but it did not help.

The problem is in this expression: glob.glob(path + "/StudentsBySchool.csv") . The pattern you pass to the glob function does not give you any hits. There could be several reasons for that:

  • pycharm starts python from a different (unexpected) working directory
  • you did not copy the csv files to the right folder

allFiles is an empty list, and Sframe = pd.concat(list,ignore_index=False) then tries to concat an empty list of data frames which gives you the error.

I would suggest printing out os.path.abspath(os.curdir) and path + "/StudentsBySchool.csv" and verify that this pattern indeed matches your csv files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM