Python Forum

Full Version: Attribute error in Dataframes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import webbrowser
website='https://en.wikipedia.org/wiki/NFL_win-loss_records'
webbrowser
output--><module 'webbrowser' from 'C:\\Users\\Anish\\anaconda3\\lib\\webbrowser.py'>

webbrowser.open
output--> <function webbrowser.open(url, new=0, autoraise=True)>

webbrowser.open(website)
Output--> True

nfl_frame = pd.read_clipboard()
ngl_frame

Output: Rank Team GP Won Lost Tied Pct. First NFL Season Division
0 1 Dallas Cowboys 914 520 388 6 0.572 1960 NFC East
1 2 Green Bay Packers 1,368 756 574 38 0.567 1921 NFC North
2 3 New England Patriots 916 512 395 9 0.564 1960 AFC East
3 4 Chicago Bears 1,402 769 591 42 0.563 1920 NFC North
4 5 Baltimore Ravens 384 214 169 1 0.559 1996 AFC North

Input--> nfl_frame.Rank
Output-->--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-660136ad565c> in <module>
----> 1 nfl_frame.Rank

~\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5273 return self[name]
-> 5274 return object.__getattribute__(self, name)
5275
5276 def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'Rank'
Use code tags.
Read as html pd.read_html the pick out correct table,the it should work.
Here a NoteBook.