Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Fintech Resource

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

FINTECH PYTHON RESOURCE

IMPORT THE LIBRARY (ICAP PAST PAPER)

Brief of the Code:


In the exam most probable the first code will need will be to read different libraries.

Code
For Pandas: import pandas as pd
For matplotlib: impot matplotlib.pyplot as plt
For seaborn : import seaborn as sns

READ CSV FILE FROM COMPUTER (ICAP PAST PAPER)

Brief of the Code:


The code will impot the csv file in the python where we will be able to manipulate the csv.

Code:
Cars_data=pd.read_csv(r’address in the computer where the file is saved’) …. The easiest way
is to copy from address bar of the windows as follow:

Accordingly, the code will look like this:

Cars_data=pd.read_csv(r’ C:\Users\hmushtaq002\Desktop\Data\CARSALES.csv’)

CHANGE FORMAT TO DATE (ICAP PAST PAPER)

Brief of the Code:


The code will change the format to date.

Code:

df1['Latest_Launch']=pd.to_datetime(df1['Latest_Launch'])

To check the format is changed use the following code:

df1.info()
FINTECH PYTHON RESOURCE

CHANGE COLUMN NAME (ICAP PAST PAPER)

Brief of the Code:


In this code existing column named “Model” is changed to “Company”.

Code
new=csales.rename(columns={'Model':'Company'})

INSERT COLUMN WHICH GIVES THE PRODUCT OF TWO COLUMNS

Brief of the Code:


The code will give product of two columns one from existing csv file and one from other.

Code

Csales[‘Revenue’]= Csales[‘sale_price’]* Sales[‘units’]

INSERT COLUMN NAME BETWEEN SPECIFIC TWO COLUMNS

Brief of the Code:


In this code a new column named “'new_column” is inserted at a specific place i.e 2 shows the
position of the insertion of the column. Further to enter data into new column you may wither add
constant value or link to existing data set as in this case the data from existing column “Model”
from csales has been used.

Code
csales.insert(2,'new_column',csales['Model'])

REPLACE

Brief of the Code:


In this code specific value/data is replace. Here ‘Acura’ from all the csv file has been replaced
with ‘replaced.’

Code
replaced=csales.replace('Acura','replaced')

DUPLICATE VALUES (ICAP PAST PAPER)

Brief of the Code:


In this code the sum of duplicated values from all the csv file is calculated. Please note that the
code will only give duplicated values if 100% similar rows are duplicated i.e. if two rows are 100%
same then the code with result answer 2.
FINTECH PYTHON RESOURCE

Further, to find duplicated values from the specific column then refer to Code 2 where it will revert
the duplicated values in the entire selected column.

Codes

Code 1: dup=csales.duplicated().sum()
Code 2: dup=csales[‘specific_column’].duplicated().sum()

GROUPBY (ICAP PAST PAPER) VERY IMPORTANT FUNCTION FOR ANALYZING DATA

Brief of the Code:


This function will make group of the data and then return the values in summarized form of all the
other columns i.e. in the below code the code will revert the sum of all columns like sales in
thousand according to the manufacturer companies. Better clarity will be achieved by running the
code.

a=csales.groupby('Manufacturer').sum()

Brief of the Code:


Further to the above code, if only grouping of data is required specific to only one column, then
the below code will be used i.e. need summary of manufactures and sales in thousand without
any other column summary.

a=csales.groupby('Manufacturer')[‘sales_in_thousand’].sum()

FILTER ROWS IN ACCORDANCE WITH SPECIFIC CONDITION/VALUES

Brief of the code


In this code rows are selected where the value is exceeding amounting to 100000.

Code

fs = csales[csales['Sales'] > 100000]……………………’The code will filter from ‘sales column’.

To provide more clarity about how the code might be used, the follow code will help. In the given
below code No. of entries are counted which exceed value 100000.

gsales=fs.groupby('Manufacturer')
result=gsales.size()
print (result)
FINTECH PYTHON RESOURCE

REINDEXING

Brief of the Code:

This code will reset the existing index and will create new index i.e in this case the new index
would show B D A C E

Code
df1.reindex([‘B’, ‘D’, ‘A’, ‘C’, ‘E’]))

LOWEST AND HIGHEST VALUES (PAST PAPER)

Brief of the code:

This code will look for the top highest/lowest value from the selected column and give the entire
data for the highest/lowest values i.e In the below code the code will look for the top 5
highest/lowest from the column “Sales” and will give the data of all columns in respect of the
highest/lowest values from ‘Sales’.

Code:

top_5_highest = csales.nlargest(5, 'Sales')


top_5_lowest = csales.nsmallest(5, 'Sales')

MINIMUM AND MAXIMUM VALUE

Brief of the Code:

This code will revert the maximum (largest) or smallest value form the selected column.

Code:

min_value=df['fees'].min()

max_value=df['fees'].max()

SELECTING SPECIFIC ROWS

Brief of the Code:


This code will help to select only specific rows in accordance with the index.

Code:

Df.iloc[:15]………..This code will only select first 15 rows.


Df.iloc[5:15]………..Likewise, this code will select only rows from row no 5 to row no 15.
Df.iloc[5:]………..Likewise, this code will select all rows from row no 5 and onwards.
FINTECH PYTHON RESOURCE

LIMITED ROWS SELECTION WITH GIVEN COLUMN

Brief of the Code:

This code will help to select only specific rows and provide data from specific columns only.

Code:
print(df.loc[1:3, ['Name', 'Qualification']])

SELECT ROWS WHERE MANUFACTURER IS 'FORD'

Brief of the Code:

The code will revert the only rows which value/date is same as prescribed in the code.

Code:
specific_rows = car_sales_df[car_sales_df['Manufacturer'] == 'Ford']
print(specific_rows)

ASCENDING/DESCENDING ORDER

Brief of the Code

The following code will sort the rows in accordance with the selected column.

Code:

Sort =csales.sort_values(by='Total_Sales_in_Thousands', ascending=False)… For descending


Sort =csales.sort_values(by='Total_Sales_in_Thousands', ascending=True)…For ascending

RENAME COLUMNS
DISCUSS WITH AQIB
Brief of the code:

The code will reindex the existing index.

Code

Indexing=csales.reset_index()
Indexing.columns = ['Manufacturer', 'Total_Sales_in_Thousands']
FINTECH PYTHON RESOURCE

MEAN, MEDIAN (ICAP PAST PAPER)

Brief of the Code

The code will calculate the mean and median of the selected column in the csv file.

Code:

Mean=csales[‘sales’].mean()
median=csales[‘sales’].median()

SAVING CSV FILE

Brief of the Code

The code will save the changes to new csv file.

Code:
df1.to_csv(‘new_filename.csv', index=False)
FINTECH PYTHON RESOURCE

GRAPHS

LINE GRAPH (PAST PAPER)

CODE: (values are different from ICAP past paper)

import matplotlib.pyplot as plt


import pandas as pd

# Create sample data


import numpy as np
np.random.seed(0)
dates = pd.date_range('2023-01-01', periods=100)
data = pd.DataFrame(np.random.randn(100, 3), index=dates, columns=['Line1', 'Line2', 'Line3'])

The above highlighted code my be ignored since in the


exam we have to select data from the csv file.

plt.plot(data.index, data['Line1'], label='Line 1', color='blue')


plt.plot(data.index, data['Line2'], label='Line 2', color='green')
plt.plot(data.index, data['Line3'], label='Line 3', color='red')

plt.title('Sample 3-Line Graph')


plt.xlabel('Date')
plt.ylabel('Values')
plt.grid()
FINTECH PYTHON RESOURCE

plt.legend(loc='upper right')
plt.show()

BAR GRAPH

Code:

import matplotlib.pyplot as plt

origin = ['USA', 'Asia', 'Europe']


revenue = [1750, 750, 250]

plt.figure(figsize=(10, 6))
plt.bar(origin, revenue, color=['blue', 'orange', 'green'])

plt.title('Revenue by Car Origin')


plt.xlabel('Origin')
plt.ylabel('Revenue (in millions)')
plt.show()

Import links to practice the basics for drawing the graphs which must be prepared before going to
exams:

Matplotlib Library

https://www.w3schools.com/python/matplotlib_intro.asp
FINTECH PYTHON RESOURCE

Ensure to complete the codes for different types of graphs i.e Bar Chart, Pie Chart, Scatter plot,
Histogram.

Other Libraries:

Pandas Library
https://www.w3schools.com/python/pandas/default.asp

NOTE:

PROGRAMMING PART

The above codes have been prepared based on the ICAP past paper of the recent attempt which
will surely help to understand the pattern of the past papers and will enable you people to be on
track without wasting time on unnecessary codes. Many above codes have been written on my
presumptions which were not asked by the ICAP but are extension to the ICAP questions.

THEORETICAL PART

Further, in respect of other part of the FINTECH (other than programing part) basic understanding
of the terminologies is must since the entire part will be MCQ’s based. Moreover, the competition
of this part is not possible (according to me) because the scope of the syllabus is sky and no
specific study material is provided, accordingly ICAP in the exam uses advanced terminologies
which we might not be able to understand but anyone will definitely gain passing marks from the
theoretical area based on the understandings of the lectures.

DISCLAMER:

The provided material is based on my recent attempt and the ICAP Model paper on FINTECH. It
is intended to serve as a guiding resource for understanding key concepts. Please note that this
material is not exhaustive. To ensure success in the exam, all candidates should verify the
completeness of their study material and syllabus coverage. The above codes have not been
checked for error which may result error while running code, accordingly, copy and paste the code
in chatgpt and you will get right code.

The above document is still in progress and will share the final version after completing further
important codes. Feel free to contact me to discuss the document and provide any suggestions
you may have on the subject matter.

Regards

Hamza Mushtaq
PwC Islamabad
Contact: 03420148917 (Only WhatsApp)

You might also like