0% found this document useful (0 votes)
29 views2 pages

1BY20IS415 - Python Assignment (Attendance Percentage) - Jupyter Notebook

Uploaded by

1by20is415
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)
29 views2 pages

1BY20IS415 - Python Assignment (Attendance Percentage) - Jupyter Notebook

Uploaded by

1by20is415
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/ 2

1/24/22, 12:08 PM Python assignment(attendance percentage) - Jupyter Notebook

In [1]:

import pandas as pd

In [2]:

df = pd.read_csv(r"Attendance.csv.csv")

In [3]:

print(df)

SLno USN 01-01 02-01 03-01 04-01 05-01 06-01


0 1 1 P P P A A A
1 2 2 P P P A A A
2 3 3 P P P A P P
3 4 4 P P P P P P
4 5 5 P P A A A A
5 6 6 P A A A A A
6 7 7 A A A A A A

In [4]:

df.replace(to_replace ="P",
value = "1",
inplace = True)

In [5]:

print(df)

SLno USN 01-01 02-01 03-01 04-01 05-01 06-01


0 1 1 1 1 1 A A A
1 2 2 1 1 1 A A A
2 3 3 1 1 1 A 1 1
3 4 4 1 1 1 1 1 1
4 5 5 1 1 A A A A
5 6 6 1 A A A A A
6 7 7 A A A A A A

In [6]:

df.replace(to_replace ="A",
value = "0",
inplace = True)
print(df)

SLno USN 01-01 02-01 03-01 04-01 05-01 06-01


0 1 1 1 1 1 0 0 0
1 2 2 1 1 1 0 0 0
2 3 3 1 1 1 0 1 1
3 4 4 1 1 1 1 1 1
4 5 5 1 1 0 0 0 0
5 6 6 1 0 0 0 0 0
6 7 7 0 0 0 0 0 0

localhost:8888/notebooks/Python assignment(attendance percentage).ipynb 1/2


1/24/22, 12:08 PM Python assignment(attendance percentage) - Jupyter Notebook

In [7]:

df['01-01'] = df['01-01'].astype(int)

In [8]:

df['02-01'] = df['02-01'].astype(int)
df['03-01'] = df['03-01'].astype(int)
df['04-01'] = df['04-01'].astype(int)
df['05-01'] = df['05-01'].astype(int)
df['06-01'] = df['06-01'].astype(int)

In [9]:

print(df)

SLno USN 01-01 02-01 03-01 04-01 05-01 06-01


0 1 1 1 1 1 0 0 0
1 2 2 1 1 1 0 0 0
2 3 3 1 1 1 0 1 1
3 4 4 1 1 1 1 1 1
4 5 5 1 1 0 0 0 0
5 6 6 1 0 0 0 0 0
6 7 7 0 0 0 0 0 0

In [10]:

sum_column = df["01-01"] + (df["02-01"]) + df["03-01"] + df["04-01"] + df["05-01"] + df["06


df["total"] = (sum_column/6)*100
print(df)

SLno USN 01-01 02-01 03-01 04-01 05-01 06-01 total


0 1 1 1 1 1 0 0 0 50.000000
1 2 2 1 1 1 0 0 0 50.000000
2 3 3 1 1 1 0 1 1 83.333333
3 4 4 1 1 1 1 1 1 100.000000
4 5 5 1 1 0 0 0 0 33.333333
5 6 6 1 0 0 0 0 0 16.666667
6 7 7 0 0 0 0 0 0 0.000000

In [ ]:

localhost:8888/notebooks/Python assignment(attendance percentage).ipynb 2/2

You might also like