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

Project On World University Rankings

The document describes a Python program for analyzing world university ranking data. It loads ranking data from a CSV file and provides a menu-driven interface to display, access, manipulate, analyze, and visualize the data. Key functionality includes selecting rows and columns, boolean indexing, deleting/updating/renaming data, calculating summary statistics, and sorting/grouping the data.

Uploaded by

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

Project On World University Rankings

The document describes a Python program for analyzing world university ranking data. It loads ranking data from a CSV file and provides a menu-driven interface to display, access, manipulate, analyze, and visualize the data. Key functionality includes selecting rows and columns, boolean indexing, deleting/updating/renaming data, calculating summary statistics, and sorting/grouping the data.

Uploaded by

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

#Project on World University Rankings

import matplotlib.pyplot as mp

import numpy as np

import pandas as pd

df = pd.read_csv('C:\\Users\\User2\\OneDrive\\Desktop\\world_

university_rankings.csv',nrows = 250)

while True :

print('-----------------------------------')

print('| WORLD UNIVERSITY RANKING PROJECT |','\n')

print('------------------------------------','\n')

print('| MAIN MENU |')

print('-----------------------------------')

print('''| 1.Display Data |

\n| 2. Accessing Data |

\n| 3. Data Manipulation |

\n| 4. Data Analysis |

\n| 5. Data Visualisation |

\n| 6. Exit |''')

print('-----------------------------------')

print()

ch = int(input('Enter your choice :'))

if ch == 1:

print('--------------------------')

print('| Display Data |')

print('--------------------------')

print('''| 1.Display full data |

  \n| 2.Display first n rows    |

\n| 3.Display last n rows |

\n| 4.Boolean Indexing |

\n| 5.Exit |''')

print('----------------------------')
print()

dis = int(input('Enter your choice :'))

print()

if dis == 1 :

print('---{ DISPLAYING FULL DATA }---')

print()

print(df)

elif dis == 2 :

print('---{ FIRST n ROWS }---')

print()

f = int(input('Enter number of rows to be dispalyed:'))

print()

print(df.head(f))

elif dis == 3 :

print('---{ LAST n ROWS }---')

print()

s = int(input('Enter number of rows to be displayed :'))

print()

print(df.tail(s))

elif dis == 4:

print('------------------------')

print('| BOOLEAN INDEXING |')

print('------------------------')

print('''| 1.World Rank |

\n| 2.National Rank |

\n| 3.Quality of Faculty |

\n| 4.Exit |''')

print('------------------------')

print()

bo = int(input('Enter your choice :'))

print()
if bo == 1:

print(df.Worldrank)

b1 = int(input('Enter the limit:'))

print('-------------------')

print('| WORLD RANK |')

print('-------------------')

print('| 1.More than ', b1,'|'

' \n| 2.Less than ',b1,'|'

' \n| 3.Equal to ', b1,' |'

' \n| 4.Exit |')

print('--------------------')

print()

ch = int(input('Enter your choice :'))

if ch == 1:

print(df.Worldrank>100)

elif ch == 2:

print(df.Worldrank<250)

elif ch == 3:

print(df.Worldrank == 100)

elif ch == 4:

pass

else :

print('INVALID INPUT')

elif bo == 2:

print(df.Nationalrank)

b2 = int(input('Enter the limit:'))

print('----------------------')

print('| NATIONAL RANK |')

print('----------------------')

print('| 1.More than ',b2,' |'

' \n| 2.Less than ',b2,' |'


' \n| 3.Equal to ',b2 ,' |'

' \n| 4.Exit |')

print('----------------------')

print()

ch = int(input('Enter your choice :'))

if ch == 1:

print(df.Nationalrank>5)

elif ch == 2:

print(df.Nationalrank<58)

elif ch == 3:

print(df.Nationalrank == 10)

elif ch == 4:

pass

else :

print('INVALID INPUT')

elif bo == 3:

print(df.Qualityoffaculty)

b3 = int(input('Enter the limit:'))

print('------------------------')

print('| QUALITY OF FACULTY |')

print('------------------------')

print('| 1.More than ',b3,' |'

' \n| 2.Less than ',b3,' |'

' \n| 3.Equal to ',b3 ,' |'

' \n| 4.Exit |')

print('------------------------')

print()

ch = int(input('Enter your choice :'))

if ch == 1:

print(df.Qualityoffaculty>94)

elif ch == 2:
Informatics Practices with Python–XII

A.4

print(df.Qualityoffaculty<101)

elif ch == 3:

print(df.Qualityoffaculty ==10)

elif ch == 4:

pass

else :

print('INVALID INPUT')

elif bo == 4:

pass

else:

print('INVALID CHOICE')

elif dis == 5:

pass

else :

print('INVALID CHOICE')

elif ch == 2:

print('-------------------------')

print('| ACCESSING DATA |')

print('-------------------------')

print('''| 1.Scalar Value |

\n| 2.Individual columns |

\n| 3.Multiple columns |

\n| 4.subset |

\n| 5.Individual rows |

\n| 6.Multiple rows |

\n| 7.Exit |''')

print('-------------------------')

print()

a = int(input('Enter your choice :'))


if a == 1:

print()

print('--{ COLUMN NAMES }--')

for i in df.columns:

print(i)

sc = input('Enter the column name to be accessed:')

sc = sc.capitalize()

ro = int(input('Enter the index number of the row to be

accessed:'))

print()

print('------------------------------')

print('| ACCESSING SCALAR VALUE |')

print('------------------------------')

print(df[sc][ro])

elif a == 2:

print(df.columns)

print()

ai = input('Enter the COLUMN to be accessed:')

ai = ai.capitalize()

print()

print('-----------------------------------')

print('| ACCESSING INDIVIDUAL COLUMN |')

print('-----------------------------------')

print(df[ai])

elif a == 3:

print(df.columns)

print()

ac = int(input('Enter the number of COLUMNS to be accessed:'))

n = []

for i in range(ac):

s = input('Enter the column name:')


s = s.capitalize()

n.append(s)

print()

print('--------------------------------')

print(' ACCESSING MULTIPLE COLUMNS ')

print('--------------------------------')

print(df[n])

elif a == 4:

print(df.columns)

print()

s1 = int(input('Enter the starting row index:'))

s2 = int(input('Enter the ending row index:'))

s3 = input('Enter the starting column:')

s4 = input('Enter the ending column:')

s3 = s3.capitalize()

s4 = s4.capitalize()

print()

print('---------------')

print('| SUBSETS |')

print('---------------')

print(df.loc[s1:s2,s3:s4])

elif a == 5:

print(df.columns)

print()

i1 = int(input('Enter the row index to be accessed: '))

print()

print('-------------------------------')

print('| ACCESSING INDIVIDUAL ROW |')

print('-------------------------------')

print(df.loc[i1])

elif a == 6:
print(df.columns)

print()

i1 = int(input('Enter the starting row index:'))

print()

i2 = int(input('Enter the ending row index:'))

print()

print('------------------------------')

print('| ACCESSING MULTIPLE ROWS |')

print('------------------------------')

print(df.loc[i1:i2])

elif a == 7:

pass

else :

print('Invalid Choice')

elif ch == 3:

print('------------------------')

print('| Data Manipulation |')

print('------------------------')

print('''| 1.Delete |

\n| 2.Rename |

\n| 3.Update |

\n| 4.Exit |''')

print('------------------------')

print()

man = int(input('Enter Your Choice:'))

if man == 1 :

print('-------------------------------')

print('| DELETE |')

print('-------------------------------')

print('''| 1.Delete Single Row |

\n| 2.Delete Multiple rows |


\n| 3.Delete Single column |

\n| 4.Delete Multiple column |

\n| 5.Exit |''')

print('-------------------------------')

print()

p = int(input('Enter your choice:'))

if d == 1:

print()

i = int(input('Enter the index number of the row to be

deleted:'))

delete = df.drop(i)

print(delete)

print('ROW DELETED')

elif d == 2:

print()

r = int(input('Enter the number of rows to be deleted:'))

print()

for i in range(r):

re = int(input('Enter the row index to be deleted:'))

delete = df.drop(re)

print(delete)

print('ROWS DELETED')

elif d == 3:

print(df.columns)

print()

c = input('Enter the column name to be deleted:')

c = c.capitalize()

delete = df.drop(c,axis = 1)

print(delete)

print('COLUMN DELETED')

elif d == 4:
print(df.columns)

print()

c = int(input('Enter the number of columns to be deleted:'))

print()

for i in range(c):

re = input('Enter the column name to be deleted:')

re = re.capitalize()

delete = df.drop(re,axis = 1)

print(delete)

print('COLUMNS DELETED')

elif d == 5:

pass

else :

print('INVALID CHOICE')

elif man == 2 :

print('-------------------------------')

print('| RENAME |')

print('-------------------------------')

print('''| 1.Rename single column |

\n| 2.Rename multiple column |

\n| 3.Exit |''')

print('-------------------------------')

print()

r = int(input('Enter your choice:'))

if r == 1:

print(df.columns)

print()

r1 = input('Enter the column to be renamed:')

r1 = r1.capitalize()

print()

r2 = input('Enter the new name to be put:')


r2 = r2.capitalize()

re = df.rename(columns = {r1:r2},inplace = False)

print(re)

print('COLUMN RENAMED')

elif r == 2:

print(df.columns)

print()

rc = int(input('Enter the number of columns to be

renamed:'))

di = {}

for i in range(rc):

x = input('Enter the column to be renamed:')

x = x.capitalize()

print()

y = input('Enter the new name to be put:')

y = y.capitalize()

re2 = df.rename(columns = {x:y},inplace = False)

print(re2)

print('COLUMNS RENAMED')

elif r == 3:

pass

else:

print('INVALID CHOICE')

elif man == 3:

print('-------------------------------------')

print('| UPDATE |')

print('-------------------------------------')

print('''| 1.Update Particular value |

\n| 2.Exit |''')

print('-------------------------------------')

print()
u = int(input('Enter your choice:'))

if u == 1:

print(df.columns)

print()

u1 = input('Enter column name :')

u1 = u1.capitalize()

r = int(input('Enter the index number of row:'))

print()

u2 = input('Enter the new value:')

if type(u2) == int:

u2 = int(u2)

n =df.at[r,u1] = u2

else:

n = df.at[r,u1] = u2

print(n)

print(df)

print('COLUMN UPDATED')

elif man == 4:

pass

else:

print()

print('INVALID CHOICE')

elif ch == 4:

print('---------------------------------------')

print('| DATA ANALYSIS |')

print('---------------------------------------')

print('''| 1.Minimum value |

\n| 2.Maximum value |

\n| 3.Information regarding data |

\n| 4.Shape |

\n| 5.Mean |
\n| 6.Median |

\n| 7.Mode |

\n| 8.Sort |

\n| 9.Group by|

\n| 10.Exit |''')

print('---------------------------------------')

print()

an = int(input('Enter Your Choice:'))

print()

if an == 1:

print(df.columns)

print()

print('TO DISPALY THE MINIMUM VALUE')

print()

m = input('Enter the column name:')

m = m.capitalize()

print()

print('Min Value:',df[m].min())

elif an == 2:

print(df.columns)

print()

print('TO DISPALY THE MAXIMUM VALUE')

print()

m = input('Enter the column name:')

m = m.capitalize()

print()

print('Max Value:',df[m].max())

elif an == 3:

print('THE INFORMATION REGARDING DATA')

print()

print(df.info())
elif an == 4:

print('SHAPE OF THE DATA')

print()

print(df.shape)

elif an == 5:

print(df.columns)

print('TO GET THE MEAN FROM THE DATA')

print()

m = input('Enter the column name:')

m = m.capitalize()

print(df[m].mean())

elif an == 6:

print(df.columns)

print('TO GET THE MEDIAN FROM THE DATA')

print()

m = input('Enter the column name:')

m = m.capitalize()

print(df[m].median())

elif an == 7:

print(df.columns)

print('TO GET THE MODE FROM THE DATA')

print()

m = input('Enter the column name:')

m = m.capitalize()

print(df[m].mode())

elif an == 8:

print('------------------------------')

print('| SORT |')

print('------------------------------')

print('''| 1.Sort in Ascending order |

\n| 2.Sort in Descending order |


\n| 5.Exit |''')

print('------------------------------')

print()

z = int(input('Enter your choice:'))

if z == 1:

print(df.columns)

print()

print('FOR SORTING IN ASCENDING ORDER')

print()

s = input('Enter the column name:')

s = s.capitalize()

print()

print(df.sort_values(s,inplace = False))

print()

print('SORTED IN ASCENDING ORDER')

elif z == 2:

print(df.columns)

print()

print('FOR SORTING IN DESCENDING ORDER')

print()

s = input('Enter the column name:')

s = s.capitalize()

print()

print(df.sort_values(s,inplace = False,ascending =

False))

print()

print('SORTED IN DESCENDING ORDER')

elif z == 3:

pass

else:

print('INVALID CHOICE')
  elif an == 9:

print('-------------------------------')

print('| GROUP BY |')

print('-------------------------------')

print('''| 1.Group by count function |

\n| 2.Group by average function |

\n| 5.Exit |''')

print('-------------------------------')

print()

o = int(input('Enter your choice:'))

if o == 1:

print(df.columns)

print()

print('TO GROUP BY COUNT FUNCTION')

print()

o1 = input('Enter the first column name:')

o1 = o1.capitalize()

print()

o2 = input('Enter the second column name:')

o2 = o2.capitalize()

print(df.groupby(o1)[o2].count())

print()

elif o == 2:

print(df.columns)

print()

print('TO GROUP BY AVERAGE FUNCTION')

print()

o1 = input('Enter the first column name:')

o1 = o1.capitalize()

print()

o2 = input('Enter the second column name:')


o2 = o2.capitalize()

av = df.groupby(o1)[o2].mean()

print(av)

print()

elif o == 3:

pass

else:

print('INVALID CHOICE')

elif an == 10:

pass

else:

print('INVALID CHOICE')

elif ch == 5:

print('----------------------------------------------')

print('| DATA VISUALISATION |')

print('----------------------------------------------')

print('''| 1.World Rank & Score |

\n| 2.Quality of Education & Quality of Faculty I

\n| 3.National Rank & Influence|

\n| 4.Exit |''')

print('----------------------------------------------')

print()

v = int(input('Enter Your Choice:'))

print()

if v == 1:

print('------------------------------')

print('| WORLD RANK & SCORE |')

print('------------------------------')

print('''| 1.Scatter Chart |

\n| 2.Bar Chart |

\n| 3.Histogram |
\n| 4.Exit |''')

print('------------------------------')

print()

ap = int(input('Enter your choice:'))

if ap == 1:

mp.scatter(df.Score,df.Worldrank,color = 'pink',

label = 'World Rank')

mp.title('WORLD RANK & SCORE SCATTER CHART')

mp.xlabel('SCORE')

mp.ylabel('WORLD RANK')

mp.legend()

mp.show()

elif ap == 2:

df.groupby('Worldrank')['Score'].plot.bar(color =

'pink',edgecolor = 'black',legend=True)

mp.title('WORLD RANK & SCORE BAR CHART')

mp.xlabel('SCORE')

mp.ylabel('WORLD RANK')

mp.show()

elif ap == 3:

df.groupby('Worldrank')['Score'].plot.hist(legend=True)

mp.title('WORLD RANK & SCORE HISTOGRAM')

mp.xlabel('SCORE')

mp.ylabel('WORLD RANK')

mp.xticks([5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100])

mp.show()

elif ap == 4:

pass

else:

print('INVALID CHOICE')

elif v == 2:
print('------------------------------------------')

print('|Quality of Education & Quality of Faculty| ')

print('------------------------------------------')

print('''| 1.Scatter Chart |

\n| 2.Bar Chart |

\n| 3.Histogram |

\n| 4.Exit |''')

print('------------------------------------------')

print()

ip = int(input('Enter your choice:'))

if ip == 1:

mp.scatter(df.Qualityoffaculty,df.Qualityofeducation,color =

'brown',label = 'Quality of Education')

mp.title('Quality of Education & Quality of Faculty

SCATTER CHART')

mp.xlabel('Quality of Faculty')

mp.ylabel('Quality of Education')

mp.legend()

mp.show()

elif ip == 2:

h = df.head(100)

    mp.bar(h.Qualityoffaculty,h.Qualityofeducation,

label = 'Quality of Education',color =

'brown',edgecolor = 'black')

mp.title('Quality of Education & Quality of Faculty

BAR CHART')

mp.xlabel('Quality of Faculty')

mp.ylabel('Quality of Education')

mp.legend()

mp.show()

elif ip == 3:
mp.hist(df.Qualityofeducation,color =

'brown',edgecolor = 'black',label =

'Quality of Education')

mp.title('Quality of Education & Quality of Faculty

HISTOGRAM')

mp.xlabel('Quality of Faculty')

mp.ylabel('Quality of Education')

mp.legend()

mp.show()

elif ip == 4:

pass

else:

print('INVALID CHOICE')

elif v == 3:

print('------------------------------')

print('| NATIONAL RANK AND INFLUENCE |')

print('------------------------------')

print('''| 1.Scatter Chart |

\n| 2.Bar Chart |

\n| 3.Histogram |

\n| 4.Exit |''')

print('------------------------------')

print()

choice = int(input('Enter your choice:'))

if choice == 1:

mp.scatter(df.Nationalrank,df.Influence,label ='Influence',color = 'orange')

mp.title('NATIONAL RANK AND INFLUENCE SCATTER

CHART')

mp.xlabel('NATIONAL RANK')

mp.ylabel('INFLUENCE')

mp.legend()
mp.show()

elif choice == 2:

h = df.head(100)

mp.bar(h.Nationalrank,h.Influence,color ='orange',label = 'Influence',edgecolor ='black')

mp.title('NATIONAL RANK AND INFLUENCE BAR CHART')

mp.xlabel('NATIONAL RANK')

mp.ylabel('INFLUENCE')

mp.legend()

mp.show()

elif choice == 3:

mp.hist(df.Influence,color = 'orange',label ='Influence',edgecolor = 'black')

mp.title('NATIONAL RANK AND INFLUENCE HISTOGRAM')

mp.xlabel('NATIONAL RANK')

mp.ylabel('INFLUENCE')

mp.legend()

mp.show()

elif choice == 4:

pass

else:

print('INVALID CHOICE')

elif ch == 6:

pass

else:

print('INVALID CHOICE')

You might also like