Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question to Loc
#2
(May-10-2018, 11:15 AM)Jack_Sparrow Wrote: ....
df= babynames.loc[babynames.'Top Name'=='Michael', :]

This should have given you exception. You may use dot reference to a column only if it can be tokenized to a legal Python name - which is not the case. Second selector is redundant
df= babynames.loc[babynames['Top Name']=='Michael']
will do the trick

PS And now mods will give you grief for bad formatting - and they will be right
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
Question to Loc - by Jack_Sparrow - May-10-2018, 11:15 AM
RE: Question to Loc - by volcano63 - May-10-2018, 11:40 AM
RE: Question to Loc - by Jack_Sparrow - May-10-2018, 11:49 AM

Forum Jump:

User Panel Messages

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