Difference makes the DIFFERENCE
import pandas as pd
import numpy as np
s = pd.Series([0,1,1,2,3,5,8,13])
print(s)
s = pd.Series([0.0,1,1,2,3,5,8,13])
print(s)
s.values
s.index
print(s.index)
for v in s.values: print(v)
for i in s.index: print (i)
for item in zip(s.values, s.index): print (item)
s[0]
s[2]
mercury = pd.Series([0.33, 57.9, 4222.6], ['mass', 'diameter', 'dayLength'])
print(mercury)
print(mercury('mass'))
print(mercury['mass'])
print(mercury['dayLength'])
mercury.mass
mercury.dayLength
arr = np.random.randint(0, 10, 10)
print(arr)
arr
rand_series = pd.Series(arr)
print(rand_series)
ind = np.arange(10, 20)
rand_seriess = pd.Series(arr, ind)
print(rand_seriess)
## mercury = pd.Series([0.33, 57.9, 4222.6], ['mass', 'diameter', 'dayLength'])
d = {}
d['mass'] = 0.33
d['diameter'] = 57.9
d['dayLength'] = 4222.6
mercury = pd.Series(d)
print(mercury)
mercury = pd.Series(d, index = ['mass', 'diameter'])
print(mercury)
mercury = pd.Series(d, index = ['mass', 'diameter', 'dayLength'])
print(mercury)
import pandas as pd
import numpy as np
s = pd.Series([0.0,1,1,2,3,5,8,13], index=[1,2,3,4,5,6,7,8])
print(s)
s.loc[4]
s.iloc[4]
s.iloc[0]
s.loc[0]
mercury.iloc[0]
mercury.loc['mass']
mercury.iloc[-1]
mercury.iloc[0:2] # 2 is exclusive
mercury.iloc[:2]
mercury.iloc[2:]
mercury.loc['dayLength']
mass = pd.Series([0.33, 4.87, 5.97, 0.642, 1898, 568, 86.8, 102, 0.0146],
index=['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'])
print(mass)
mass.iloc[3:]
mass.iloc[1]
mass.loc['Earth']
mass['Earth']
mass['Earth':'Jupiter'] # here Jupiter is inclusive, unlike lists being exclusive
mass.iloc[2:5]
print(mass)
mass > 100
mass[mass > 100]
mass_gr_100 = mass[mass > 100]
print(mass_gr_100)
mass[(mass > 100) & (mass < 1000)]
mass * 2
mass / 10
np.mean(mass)
np.median(mass)
np.amin(mass)
np.amax(mass)
mass + mass
big_mass = mass[(mass > 100)]
big_mass
new_mass = mass + big_mass
new_mass
pd.isnull(new_mass)
new_mass[~pd.isnull(new_mass)]
mass['Moon'] = 0.7346
mass
mass.drop(['Pluto'])
mass
mass.drop(['Moon'], inplace=True)
mass
print(0.330 * 4879)
diameter = pd.Series([4879, 120104, 12756, 6792, 142984, 120536, 51118, 49528, 2376],
index=['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'])
mass
diameter
radius = diameter / 2
print(radius)
volume = 4/3 * ((3.14) * diamter ** 3)
volume
density = mass / volume
density
dnsity = mass / ((4/3) * ((3.14) * radius ** 3))
dnsity
nift = pd.read_csv("/content/nifty.csv", index_col = 0).iloc[:,0]
nift.head()
nift.tail()
data = [0,1,1,2,3,5,8,13,21]
s = pd.Series(data)
b = s.diff()
print(b.iloc[5])
s = pd.Series("a", index=[1,2,3,4])
print(s.loc[2])
!pip install nbconvert