Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attribute Error
#1
Hi everyone,

I have this error message: AttributeError: 'NoneType' object has no attribute 'items'

when I run the code below:

[
import requests
import pandas as pd
wiki = 'https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M'
wikipedia_page = requests.get(wiki)

df_raw = pd.read_html(wikipedia_page.content, header=0)[0]
df_new = df_raw[df_raw.Borough != 'Not assigned']

df_new.head()
As it is the first tile I have this error I need some help please,

Regards
Reply
#2
please, post the full traceback you get, verbatim, in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Hi, please find below the total error track, than you for your support:

Error:
AttributeError Traceback (most recent call last) /opt/conda/envs/Python-3.7-main/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: /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/pandas/core/frame.py in _repr_html_(self) 732 GH3541, GH3573 733 """ --> 734 width, height = console.get_console_size() 735 max_columns = get_option("display.max_columns") 736 nb_columns = len(self.columns) /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/pandas/io/formats/format.py in to_html(self, buf, encoding, classes, notebook, border) 980 Buffer to write to. If None, the output is returned as a string. 981 encoding : str, default “utf-8” --> 982 Set character encoding. 983 classes : str or list-like 984 classes to include in the `class` attribute of the opening /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/pandas/io/formats/html.py in __init__(self, formatter, classes, border, table_id, render_links) 54 self.col_space = { 55 column: f"{value}px" if isinstance(value, int) else value ---> 56 for column, value in self.fmt.col_space.items() 57 } 58 AttributeError: 'NoneType' object has no attribute 'items'
Reply
#4
There is some problem with your conda/IPython environment. I don't use conda and IPython, so probably someone else will be able to help
Raiden_Arctica likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Ok, I juste changed of environnement and now it works well, Thank you for your support.

Regards
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using SHAP Library for my LSTM model - "Attribute Error" vatsalmtailor 0 2,041 Jul-13-2022, 04:34 PM
Last Post: vatsalmtailor
  error "list object has no attribute transpose()" usercat123 4 4,187 Jan-28-2022, 12:01 PM
Last Post: usercat123
  Attribute error in Dataframes deshanish 1 2,371 Jul-15-2020, 08:38 AM
Last Post: snippsat
  Attribute error - Sympy VictorG8 1 4,897 Apr-09-2020, 06:03 PM
Last Post: snippsat
  NLTK Download Attribute error laila1a 1 8,461 Jan-27-2019, 12:03 AM
Last Post: Larz60+
  [split] np.arrange error - no attribute gyan 2 6,941 Aug-19-2018, 05:38 PM
Last Post: micseydel
  Attribute Error while using tensor flow pratheep 2 6,580 Mar-16-2018, 10:50 AM
Last Post: pratheep
  np.arrange error - no attribute pksherard 3 22,695 Aug-16-2017, 09:54 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020