I have some old python code that I have to transition from 0.10 to 0.15 big jump. The old python code has multiple assignments to slices using the following structure:
condition = a['Column'] != 'option' # with lots of complex logic
df.ColumnX[condition] = new_value
I know this is a an assigning to a slice. In pandas 10 this worked, as documented in various pandas upgrades it does not work. without having to refactor the code totally is the a way of changing line 2 so that it can still use the loc method while still using the condition as defined on line 1.
I have tried:
df.loc[:,condition] = 'new_val'
but I get
IndexingError: Unalignable boolean Series key provided
can anybody suggest a syntax that would (preferably backward compatible to pandas 0.10 that would provide quick fix without re-factoring dozens of complex selections?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire