Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Eror
#4
Quote:My first question is why you to add second dataframe unless it was just for exposition purposes.
Could you explain further please. I do not understand this question.

Quote:It just is a mystery to me why the first set works and the second set does not.
You are not seeing the problem. The problem has nothing to do with one dataframe or two dataframes. The problem is that you use loc where you shouldn't.

To make this easer to see, I will show your two examples right next to each other. In this example I will use two dataframes; A and B
q = A.loc[B['machine_status']==0]['sensor_06']  # No error
q = A.loc[B.loc['machine_status']==0]['sensor_06']  # Error
And again with only one dataframe; A.
q = A.loc[A['machine_status']==0]['sensor_06']  # No error
q = A.loc[A.loc['machine_status']==0]['sensor_06']  # Error
There may be errors in the book, but I think it more likely that your problems are caused by you not seeing the code. It is very common to look at code and see what you expect to see. You will look at the example in the book and you will look at what your typed, and they will look identical because that is what you expect. It happens to all programmers all the time.
Reply


Messages In This Thread
Coding Eror - by Led_Zeppelin - Sep-17-2022, 03:36 PM
RE: Coding Eror - by deanhystad - Sep-17-2022, 04:23 PM
RE: Coding Eror - by Led_Zeppelin - Sep-18-2022, 10:03 PM
RE: Coding Eror - by deanhystad - Sep-19-2022, 03:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  invalid syntax eror Larry 3 4,177 Feb-18-2018, 05:56 PM
Last Post: buran

Forum Jump:

User Panel Messages

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