Python Forum

Full Version: Attribute Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
please, post the full traceback you get, verbatim, in error tags
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'
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
Ok, I juste changed of environnement and now it works well, Thank you for your support.

Regards