Python Forum

Full Version: Pandas - updating the original dataframe with sub selects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I have a dataframe with the follwoing columns
source	date	host	tag	adreq	adimpr	revenue	Device	deleteme
Now some of the rows have things I do not want to see, but I do not want to delete.
How do I update the dataframe.

I tried the following - but this gives a warning about updating a slice
tdf = self.dfDemands[ (self.dfDemands.deleteme == False) & (self.dfDemands.source == 'thesource') & (self.dfDemands.host == 'nameofahost') ]
tdf['deleteme'] = True
self.dfDemands.update( tdf )
Also tried
self.dfDemands['deleteme'] = (self.dfDemands.deleteme == False) & (self.dfDemands.source == 'Source') & (self.dfDemands.host == 'nameofahost')
Which although doesn't appear to error - doesn't up date either

Must be something simple... Any pointers please?

link to settingwithwarning
Nevermind, the link helped and I think it is working as required now :)