ML Labs
ML Labs
mean = 145.0
median = 150.0
minimum = 120
maximum = 165
index of minimum = 0
index of maximum = 1
sorted array= [120 140 150 150 165]
descending order [165 150 150 140 120]
stdev 14.832396974191326
variance 220.0
(array([1, 2, 4, 5]),)
['Rohit' 'Dinesh' 'Khushi' 'Deepti']
['Rohit' 'Dinesh' 'Deepti']
['Fail' 'Pass' 'Pass' 'Fail' 'Fail' 'Pass']
[ 1 2 3 4 5 12 7 16 9]
conditions [array([False, False, True, True, True]), array([ True, True, Tru
e, True, False])]
result [2 4 3 4 5]
In [ ]:
In [8]: #Broadcast
[15 20 25]
[ 50 100 150]
In [11]: #Linspace
# Returns the given number of evenly spaced vaues between the given intervals. T
In [14]: ##np.linspace(start,stop,num=50,endpoint=Ture,restep=False,dtype=None,axis=0)
[ 0. 10.]
In [ ]:
Understanding Pandas
Collection of one col -> Series
Series
is a 1-D labeled array capabale of holding values. The axis labels are collectively
referred to as the index.
Out[42]: 0 1
1 2
2 3
3 4
4 5
dtype: int64
In [43]: ser.index
In [44]: ser[1]
Out[44]: np.int64(2)
Out[46]: a 1
b 2
c 3
d 4
e 5
dtype: int64
In [47]: ser.index
In [48]: ser['b']
Out[48]: np.int64(2)
ser = pd.Series(dict_1)
ser
In [50]: ser['wednesday']
Out[50]: np.float64(114.5)
Out[51]: 0 12
1 13
2 10
3 11
4 14
5 15
6 9
dtype: int64
ser.count() = 7
ser.mean() = 12.0
ser.medidan() = 12.0
ser.max() = 15
ser.argmin() = 2
ser.argmax() = 1
ser.argsort() =
a 2
b 0
c 3
d -1
e -1
f -1
g 1
dtype: int64
C:\Users\231b078\AppData\Local\Temp\ipykernel_7980\1997554770.py:4: FutureWarnin
g: The behavior of Series.argsort in the presence of NA values is deprecated. In
a future version, NA values will be ordered last instead of set to -1.
print(ser.argsort())
C:\Users\231b078\AppData\Local\Temp\ipykernel_7980\1997554770.py:5: FutureWarnin
g: The behavior of Series.argsort in the presence of NA values is deprecated. In
a future version, NA values will be ordered last instead of set to -1.
newser = ser.argsort()
Out[80]: a 2
b 0
c 3
d -1
e -1
f -1
g 1
dtype: int64
In [81]: d = {'a':10,'b':21,'c':5,'d':24,'g':17}
ser = pd.Series(d,index=['a','b','c','d','e','f','g'])
a False
b False
c False
d False
e True
f True
g False
dtype: bool
-----------------
2
-----------------
2
In [ ]: