Can't load data from .csv file

I was just trying to see how will I be able to use the .csv file (since that is what Kaggle uses) to load dataset.
I am mentioning the path to be:
path = '/home/nbuser/'
df = pd.read_csv('/home/nbuser/train.csv')

When I am doing df.head() it shows the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/.anaconda3/lib/python3.7/site-packages/IPython/core/formatters.py in call(self, obj)
343 method = get_real_method(obj, self.print_method)
344 if method is not None:
–> 345 return method()
346 return None
347 else:

~/.anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in _repr_html_(self)
    647         # display HTML, so this check can be removed when support for
    648         # IPython 2.x is no longer needed.
--> 649         if console.in_qtconsole():
    650             # 'HTML output is disabled in QtConsole'
    651             return None

~/.anaconda3/lib/python3.7/site-packages/pandas/io/formats/console.py in in_qtconsole()
    121             ip.config.get('KernelApp', {}).get('parent_appname', "") or
    122             ip.config.get('IPKernelApp', {}).get('parent_appname', ""))
--> 123         if 'qtconsole' in front_end.lower():
    124             return True
    125     except NameError:

AttributeError: 'LazyConfigValue' object has no attribute 'lower'

   label  pixel0  pixel1  pixel2  pixel3  pixel4  pixel5  pixel6  pixel7  \
0      1       0       0       0       0       0       0       0       0   
1      0       0       0       0       0       0       0       0       0   
2      1       0       0       0       0       0       0       0       0   
3      4       0       0       0       0       0       0       0       0   
4      0       0       0       0       0       0       0       0       0   

   pixel8  ...  pixel774  pixel775  pixel776  pixel777  pixel778  pixel779  \
0       0  ...         0         0         0         0         0         0   
1       0  ...         0         0         0         0         0         0   
2       0  ...         0         0         0         0         0         0   
3       0  ...         0         0         0         0         0         0   
4       0  ...         0         0         0         0         0         0   

   pixel780  pixel781  pixel782  pixel783  
0         0         0         0         0  
1         0         0         0         0  
2         0         0         0         0  
3         0         0         0         0  
4         0         0         0         0  

[5 rows x 785 columns]
1 Like

Hey,

I am using Linux 18.04 and have the same problem as described by you.

I do get the same error when trying to display anything with pandas using my fastai 1.0 environment. I already tried:

  • a complete reinstall of my fastai 1.0 env (pandas works fine in all of my other virtual envs)
  • a complete reinstall of anaconda (reinstalled anything from scratch)

None of the above mentioned points solved the error for me.

I think the problem is “just” visualizing the data. This error is not making the rest of the notebook malfunction.

Hope we can fix this.

BR Mike

Hey,

There are some more people having the issue.

Further information and some workarounds:

BR
Mike

2 Likes

Just to copy/paste the (temporary) solution from https://github.com/jupyter/notebook/issues/4369#issuecomment-459377498

Run the following code:

get_ipython().config.get('IPKernelApp', {})['parent_appname'] = ""

And then, run the pandas code:

df = pd.read_csv(path/'texts.csv')
df.head()

5 Likes

That worked for me

That worked for me too.

thx, good fix

Thankyou! Worked like a charm.

1 Like