Subtract two dataframe with the same name different index

jaimers

There's two dataframes, all the colnames are the same but the index is different. I've tried several ways but I've been getting NaN. I'm guessing it is because it's trying to match the index but I am stuck.

I've tried:

df1.ix['Norm']-df2.ix['Norm']
df1 - df2.ix['Norm']
df1.astype(float) - df2.astype(float)

would like something like this

df1 - df2[df1.column.names]
cs95

When you don't want index-aligned arithmetic, get rid of the indexes. You can subtract the numpy arrays to the same effect:

(df1.values - df2[df1.column.names].values)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

subtract two columns of different Dataframe with python

how to combine two pandas dataframe with same format but different length index

How can I subtract specific values with different observations in the same Dataframe

Merge two rows in the same Dataframe if their index is the same?

How to subtract the two different numpy array with the same dimension

Subtract two dataframes of different size, but maintain at least the size of the first dataframe

Subtract two columns in dataframe

Operations between two rows of a dataframe with the same index

Compare two pandas dataframe with different index

Inference is showing two different variables with same name?

Same controller name in two different directories

Python - Behave - Two different steps with the same name

two different libraries using the same name types

Two functions having same body different name

Compare two columns of the same dataframe and returns a different column of the same dataframe

Compare Same and Different in Two Columns of Dataframe

MYSQL - How may i subtract two columns on two different rows, on the same table?

Subtract two columns in pandas dataframe

Combine two fields of two different log lines in same index pattern

concat two pandas DataFrame with same column/index into one DataFrame

Java - Two classes, same name, same package but in different folders

Two assemblies with same name ,same version but different public key

Two objects with the same name in the same namespace in different cpp files

Getting help on two functions with the same name in two different packages

PHP: is it posible to create two array with same name with two different dimension

LuaJ loading two functions with the same name from two different LuaScripts

How to subtract many columns on different pandas DataFrames (assuming the columns have the same name)

In Pandas : How can i subtract two dataframes values based on other two dataframe same Column which contain same Values

Subtract the values of one column for records coming from two different selections that are not necessarily the same