Saturday, 1 October 2022

5 d. Compare the results of the above analysis for the two data sets.

 5 d. Compare the results of the above analysis for the two data sets. 

Aim

In this program, we can compare the results of the two different data sets. 

 

Procedure

Step 1: Prepare the datasets to be compared

Step 2: Create the two DataFrames

Based on the above data, you can then create the following two DataFrames 

Step 3: Compare the values between the two Pandas DataFrames

In this step, you’ll need to import the NumPy package.

Let’s say that you have the following data stored in a CSV file called car1.csv

While you have the data below stored in a second CSV file called car2.csv

 

Program

import pandas as pd

import numpy as np

data_1 = pd.read_csv(r'd:\car1.csv')

df1 = pd.DataFrame(data_1)

data_2 = pd.read_csv(r'd:\car2.csv')

df2 = pd.DataFrame(data_2)

df1['amount1'] = df2['amount1']

df1['prices_match'] = np.where(df1['amount'] == df2['amount1'], 'True', 'False')

df1['price_diff'] = np.where(df1['amount'] == df2['amount1'], 0, df1['amount'] - df2['amount1'])

print(df1)

 

Output

   Model      City  Year   amount  amount1 prices_match  price_diff

0  Maruti  Chennai  2022   600000   600000         True           0

1  Hyndai  Chennai  2022   700000   700000         True           0

2    Ford  Chennai  2022   800000   850000        False      -50000

3     Kia  Chennai  2022   900000   900000         True           0

4     XL6  Chennai  2022  1000000  1000000         True           0

5    Tata  Chennai  2022  1100000  1150000        False      -50000

6    Audi  Chennai  2022  1200000  1200000         True           0

7  Ertiga  Chennai  2022  1300000  1300000         True           0

 

 

Please click here to download the Dataset

Dataset 1: car1.csv

Dataset 2: car2.csv

No comments:

Post a Comment

CCS 365 Software Defined Network Lab Manual

 CCS 365 Software Defined Network Lab Manual 1) Setup your own virtual SDN lab i) Virtualbox/Mininet Environment for SDN - http://mininet.or...