Search code examples
pythonpandasdataframejupyter-notebookseries

The truth value of a Series is ambiguous error in dataframe pandas


I currently have lots of 1000s in a column of my dataframe, I would like to change the value of this 1000 into a different number depending on whether the year given is before 2000 or after 2000 this is my code, my dataframe is called sales. year here is the current year obtained using datetime module

sales.loc[sales.remaining_lease==1000 & sales.lease_commence_date>=2000,'remaining_lease']=99-(year-sales.lease_commence_date)

Solution

  • Try:

    sales.loc[(sales.remaining_lease==1000) & (sales.lease_commence_date>=2000),'remaining_lease']=99-(year-sales.lease_commence_date)