How to get percentage difference between two columns of different DataFrames?

Xena

There are 2 DataFrames with coin pairs and float prices. Need to make new DataFrame with coin pairs and the price difference as a percentage.

First DataFrame in txt

Second DataFrame in txt

I tried this function, it didn't work

def get_diff():
    for i in df2['askPrice']:
        for x in df3['Low price']:
            i = float(i)
            x = float(x)
            try:
                if i > x:
                    res = (round(i) - round(x)) / round(x) * 100
                    print(round(res))
                else:
                    print('lower')
            except ZeroDivisionError:
                print(float('inf'))
get_diff()
Khaled DELLAL

Let's put the desired calcultaions in a new list then transform it into a column within df3

diff = [((y-x)/x)*100 for (y, x) in zip(df2['askPrice'],df3['Low price'])] 

df3['diff'] = diff

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to obtain the symmetric difference between two DataFrames?

How to get the absolute difference between values in two columns in a matrix

Calculate the difference in percentage between two columns with aliases

How to groupby columns from two dataframes and then apply aggregate difference function between rows?

How do I add another column to a dataframe in R that shows the difference between the columns of two other dataframes?

How to get difference between two array of object with different property comparer?

How to compute percentage change between corresponding elements in two dataframes r

How to compute the numerical difference between columns of different dataframes?

How to exactly merge two different DataFrames having completely different columns between them

Find closest timestamps between two dataframes and merge different columns when time difference is < 60s

Get the change in Percentage between two numbers at two different dates

How to get difference between two dates in javascript when they are of different months

R: How to get the percentage change from two different columns

How to get difference between two excel columns

How do I find the difference between two values in different dataframes across multiple rows and columns?

percentage difference between two dataframe columns (only numeric)

How to get the difference between (multiple) two different rows?

Percentage Difference Between Two Temp Columns in SQL

Find Difference Between Two DataFrames on Columns

How to get time difference between two different formats of date?

How to get difference between two dataframes?

How to get values in PowerBI between two dates in two different columns

How to make difference between two pandas dataframes?

How to get the distance between two geographic coordinates of two different dataframes?

How to find the intersection between two columns from two different dataframes

R Match two string columns between two different dataframes

How to merge two DataFrames with different columns / sizes

How to calculate percentage between two different columns in two different tables

Difference between two imbalance DataFrames columns in pyspark

TOP Ranking

HotTag

Archive