Skip to content Skip to sidebar Skip to footer

Pandas Dataframe Subtraction Result Has Row And Dtype Information

I have a simple dataframe and I compute a very simple subtraction like so: p0_cost = cost_df['price1'][cost_df['date']==p0] - \ cost_df['price2'][cost_df['date']==p0]

Solution 1:

You're creating a dict with the values of Series, if you want just the scalar value then subscript into the results using .values[0]:

p0_cost =  (cost_df['price1'][cost_df['date']==p0] - cost_df['price2'][cost_df['date']==p0]).values[0]

Post a Comment for "Pandas Dataframe Subtraction Result Has Row And Dtype Information"