Python Forum
copy of a slice from a DataFrame
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
copy of a slice from a DataFrame
#1
Hello Phyton Fans,
I just started a coursere training to learn more about phyton.
When I used the jupiter notebook provided by coursere the below code worked without error however
in my local anaconda environment the error says:

--------------
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: ....
 app.launch_new_instance()
--------------

def answer_three():
        atleastonegold = df[(df['Gold.1']+df['Gold']) >1] #df.where(df['Gold']+df['Gold.1']>1)
        atleastonegold['summerminuswinter']= atleastonegold['Gold']-atleastonegold['Gold.1'] #=ADD a new column
        return atleastonegold #atleastonegold['biggestdifference'].idxmax()
answer_three()
I am only trying to create a new column.
Reply


Messages In This Thread
copy of a slice from a DataFrame - by metalray - Feb-18-2017, 04:06 PM
RE: copy of a slice from a DataFrame - by nilamo - Feb-18-2017, 06:11 PM
RE: copy of a slice from a DataFrame - by metalray - Feb-19-2017, 04:26 PM
RE: copy of a slice from a DataFrame - by nilamo - Feb-20-2017, 04:28 PM
RE: copy of a slice from a DataFrame - by zivoni - Feb-20-2017, 11:21 PM

Forum Jump:

User Panel Messages

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