Jovian
⭐️
Sign In
In [1]:
import numpy as np
import pandas as pd
In [2]:
np.random.rand(2)
Out[2]:
array([0.83419678, 0.32687985])
In [3]:
arr = np.random.rand(5,5)
In [4]:
np.random.randint(10,100,[5,5])
Out[4]:
array([[71, 33, 19, 71, 59],
       [11, 94, 85, 43, 74],
       [73, 92, 98, 98, 52],
       [68, 85, 63, 77, 83],
       [54, 11, 28, 14, 98]])
In [5]:
arr
Out[5]:
array([[0.35888553, 0.82232463, 0.75128724, 0.3760468 , 0.49337634],
       [0.35357155, 0.69369423, 0.0789495 , 0.83533914, 0.30494082],
       [0.74500831, 0.58492219, 0.39827142, 0.84112785, 0.16462376],
       [0.8813903 , 0.32995345, 0.39567349, 0.92043628, 0.33703218],
       [0.28776373, 0.43751064, 0.16387563, 0.06115532, 0.66064708]])
In [6]:
arr = arr*100
In [7]:
arr
Out[7]:
array([[35.88855349, 82.23246304, 75.12872387, 37.60468033, 49.33763425],
       [35.35715479, 69.36942313,  7.89495033, 83.53391444, 30.4940815 ],
       [74.50083063, 58.49221914, 39.82714227, 84.1127853 , 16.46237569],
       [88.13902992, 32.99534469, 39.56734872, 92.04362802, 33.70321766],
       [28.77637313, 43.75106388, 16.38756256,  6.11553222, 66.06470771]])
In [8]:
pd.DataFrame(arr)
Out[8]:
In [9]:
subjects = []
students = []
In [10]:
sub  = input('Enter name of subnect')
Enter name of subnectMath
In [11]:
sub
Out[11]:
'Math'
In [12]:
for i in range(5):
    sub = input("Enter name of subject")
    subjects.append(sub)
Enter name of subjectMath Enter name of subjectEng Enter name of subjectPhy Enter name of subjectBio Enter name of subjectChem
In [13]:
subjects
Out[13]:
['Math', 'Eng', 'Phy', 'Bio', 'Chem']
In [14]:
for i in range(5):
    stu = input("Enter name of students")
    students.append(stu)
Enter name of studentsJonny Enter name of studentsGaddar Enter name of studentsTony Enter name of studentsStark Enter name of studentsHulk
In [15]:
students
Out[15]:
['Jonny', 'Gaddar', 'Tony', 'Stark', 'Hulk']
In [18]:
data = pd.DataFrame(arr, columns=subjects,  index=students)
In [19]:
data
Out[19]:
In [21]:
data.max(axis=1)
Out[21]:
Jonny     82.232463
Gaddar    83.533914
Tony      84.112785
Stark     92.043628
Hulk      66.064708
dtype: float64
In [22]:
data["Math"]
Out[22]:
Jonny     35.888553
Gaddar    35.357155
Tony      74.500831
Stark     88.139030
Hulk      28.776373
Name: Math, dtype: float64
In [23]:
data.loc["Tony"]
Out[23]:
Math    74.500831
Eng     58.492219
Phy     39.827142
Bio     84.112785
Chem    16.462376
Name: Tony, dtype: float64
In [24]:
data.sum(axis=1)/5
Out[24]:
Jonny     56.038411
Gaddar    45.329905
Tony      54.679071
Stark     57.289714
Hulk      32.219048
dtype: float64
In [25]:
data.sum()
Out[25]:
Math    262.661942
Eng     286.840514
Phy     178.805728
Bio     303.410540
Chem    196.062017
dtype: float64
In [26]:
data["Average"] = data.sum(axis=1)/5
In [27]:
data
Out[27]:
In [29]:
data.loc["Jonny"]
Out[29]:
Math       35.888553
Eng        82.232463
Phy        75.128724
Bio        37.604680
Chem       49.337634
Average    56.038411
Name: Jonny, dtype: float64
In [30]:
data.iloc[1:3]
Out[30]:
In [32]:
data[["Math","Phy"]]
Out[32]:
In [33]:
data[data>40]
Out[33]:
In [34]:
data>40
Out[34]:
In [36]:
data.idxmax()
Out[36]:
Math       Stark
Eng        Jonny
Phy        Jonny
Bio        Stark
Chem        Hulk
Average    Stark
dtype: object
In [37]:
data[data["Math"]<40]["Math"]
Out[37]:
Jonny     35.888553
Gaddar    35.357155
Hulk      28.776373
Name: Math, dtype: float64
In [38]:
data.max(axis=1)
Out[38]:
Jonny     82.232463
Gaddar    83.533914
Tony      84.112785
Stark     92.043628
Hulk      66.064708
dtype: float64
In [39]:
data
Out[39]:
In [40]:
%matplotlib  inline
In [41]:
data.plot.bar()
Out[41]:
<matplotlib.axes._subplots.AxesSubplot at 0x247a58f65c0>
Notebook Image
In [44]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: