0% found this document useful (0 votes)
7 views

Rajendra Reddy Task-1

material
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Rajendra Reddy Task-1

material
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1

Name: Akkala Rajendra Reddy


Rollno:21F01A0503
Mail: [email protected]
College name:St.ANN’ S COLLEGE OF ENGINEERING AND TECHNOLOGY

______________________________________________________________________ _______________________________

Question1:
import pandas as pd

df1 = pd.read_csv('Programmer.csv')
df2 = pd.read_csv('Software.csv')
df3 = pd.read_csv('Transaction.csv')
print('Dataframe1:')
df1.head()
Output:
Datafíame1:

PNAME DOB DOJ GENDER PROF1 PROF2 SALARY


0 ANAND 12-Apr-66 21-Apr-92 M PASCAL BASIC 3200
1 ALTAF 02-Jul-64 13-Nov-90 M CLIPPER COBOL 2800
2 JULIANA 31-Jan-60 21-Apr-90 F COBOL DBASE 3000
3 KAMALA 30-Oct-68 02-Jan-92 F C DBASE 2900
4 MARY 24-Jun-70 01-Feb-91 F CPP ORACLE 4500
print('Dataframe2:')
df2.head()
Output:
Datafíame2:

PNAME TITLE DEVELOPIN SCOST DCOST SOLD


0 MARY README CPP 300.00 1200 84
1 ANAND PARACHUTES BASIC 399.95 6000 43
2 ANAND VIDEO TITLING PASCAL 7500.00 16000 9
3 JULIANA INVENTORY COBOL 3000.00 3500 0
4 KAMALA PAYROLL PKG. DBASE 9000.00 20000 7
print('Dataframe3:')
df3.head()

Output:
2

Datafíame3:

customer_id txn_date txn_type txn_amount


0 429 21-01-2020 deposit 82
1 155 10-01-2020 deposit 712
2 398 01-01-2020 deposit 196
3 255 14-01-2020 deposit 563
4 185 29-01-2020 deposit 626
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question2:
import pandas as pd
cust_df=pd.read_csv('Customers.csv')
trans_df=pd.read_csv('Transaction.csv')
merged_df=pd.merge(cust_df,trans_df,on='customer_id',how='inner')
print('Merged Dataframe:')
print(merged_df.head())
Output:

~~~~~~ ~~~ ~~~~ ~~~~ ~~~ ~~~~ ~~~ ~~~~ ~~~~ ~~~ ~~~~ ~~~ ~~~~ ~~~~ ~~~ ~~~~ ~~~ ~~~~~ ~

Question3:
3

import pandas as pd
cust_df=pd.read_csv('Customers.csv')
trans_df=pd.read_csv('Transaction.csv')
merged_df=pd.merge(cust_df,trans_df,on='customer_id',how='inner')
merged_df['StartDate']=pd.to_datetime(merged_df['start_date'],format='%d-%m-%y',errors='coerce')
merged_df['EndDate']=pd.to_datetime(merged_df['end_date'],format='%d-%m-%y',errors='coerce')
merged_df['Duration']=(merged_df['EndDate']-merged_df['StartDate']).dt.days
print('Merged Dataframe With Duration:')
print(merged_df.head())
Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question4:
import pandas as pd
cust_df=pd.read_csv('Customers.csv')
trans_df=pd.read_csv('Transaction.csv')
merged_df=pd.merge(cust_df,trans_df,on='customer_id',how='inner')
merged_df['StartDate']=pd.to_datetime(merged_df['start_date'],format='%d-%m-%y',errors='coerce')
merged_df['EndDate']=pd.to_datetime(merged_df['end_date'],format='%d-%m-%y',errors='coerce')
merged_df['Duration']=(merged_df['EndDate']-merged_df['StartDate']).dt.days
merged_df=merged_df.drop_duplicates()
print('Merged Dataframe With Duration:')
print(merged_df.head())
Output:
4

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question5:
import pandas as pd
cust_df=pd.read_csv('Customers.csv')
trans_df=pd.read_csv('Transaction.csv')
merged_df=pd.merge(cust_df,trans_df,on='customer_id',how='inner')
Typ e you r t e xt
merged_df['StartDate']=pd.to_datetime(merged_df['start_date'],fo rma t='%d-%m-%y',errors='coerce')
merged_df['EndDate']=pd.to_datetime(merged_df['end_date'],format='%d-%m-%y',errors='coerce')
merged_df['Duration']=(merged_df['EndDate']-merged_df['StartDate']).dt.days
merged_df=merged_df.drop_duplicates()
merged_df=merged_df.dropna()
print('Merged Dataframe With Duration:')
print(merged_df.head())

Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question6:
import pandas as pd
cust_df=pd.read_csv('Customers.csv')
5

trans_df=pd.read_csv('Transaction.csv')
merged_df=pd.merge(cust_df,trans_df,on='customer_id',how='inner')
merged_df['StartDate']=pd.to_datetime(merged_df['start_date'],format='%d-%m-%y',errors='coerce')
merged_df['EndDate']=pd.to_datetime(merged_df['end_date'],format='%d-%m-%y',errors='coerce')
merged_df['Duration']=(merged_df['EndDate']-merged_df['StartDate']).dt.days
merged_df=merged_df.drop_duplicates()
merged_df=merged_df.dropna()
avg_duration_per_cust=merged_df.groupby('customer_id')['Duration'].mean().reset_index()
avg_duration_per_cust.rename(columns={'Duration': 'Average Duration'}, inplace=True)
print('Average Duration per Customer:')
print(avg_duration_per_cust.head())
Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question7:
unique_transaction_types=merged_df['txn_type'].unique()
print('Unique Transaction Types:')
for transaction_type in unique_transaction_types:
print(transaction_type)
Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Question8:
continent=pd.read_csv('Continent.csv')
print('Continent Dataframe:')
print(continent.head())
Output:
Type your text

import pandas as pd
cont_df=pd.read_csv('Continent.csv')
trans=merged_df.groupby(['region_id','txn_type']).size().reset_index(name='count')
print('Transaction Count per Region and Type:')
print(trans)

Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question9:
savg=df2.groupby('DEVELOPIN')['SCOST'].mean()
pas=df2[df2['DEVELOPIN']=='PASCAL']
pasavg=pas['SCOST'].mean()
print('The Average Selling Cost for packages developed in PASCAL:')
print(pasavg)
Output:
7

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question10:
df4=pd.read_csv('Studies.csv')
df4['COURSE'].unique()
Output:

df4[df4['COURSE']=='DAP']

Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question11:
lcf=df2['SCOST'].min()
print('Lowest Course Fee:',lcf)
Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question12:
rp=df2[df2['SCOST']>=df2['DCOST']]
print('Details of Packages for which Developmental Costs Have Been Recovered:')
print(rp)

Output:
8

Type your text

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question13:
bc=df2[df2['DEVELOPIN']=='BASIC']['DCOST'].max()
print('Cost of the costliest software deve in BASIC:')
print(bc)

Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question14:
df1.head()
Output:

pr=df1[((df1['PROF1']=='Programmer')|(df1['PROF2']=='Programmer'))&(df1['SALARY']>=5000)&(df1['SALARY']<=10
000)]
PC=pr.shape[0]
PC
Output:
0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question15:
cp=df1[
(df1['PROF1']=='COBOL')|(df1['PROF2']=='COBOL')|
9

(df1['PROF1']=='PASCAL')|(df1['PROF2']=='PASCAL')]
cp
c=len(cp)
print("The number of programmers who knows either COBOL or PASCAL is:" )
print(c)

Output:

______________________________________________________________________ _______________________________

You might also like