Skip to content

Instantly share code, notes, and snippets.

kind: Service
apiVersion: v1
metadata:
name: basic-ms-service
spec:
type: NodePort
selector:
app: basic-ms
ports:
- name: basic-ms-service
apiVersion: apps/v1
kind: Deployment
metadata:
name: basic-ms-deployment
spec:
replicas: 1
selector:
matchLabels:
app: basic-ms
template:
@raghumb
raghumb / .py
Created August 10, 2019 14:38
Multiple Line Plots
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# end date
end_date = dt.datetime(2018, 1, 1)
# start date
start_date = end_date - timedelta(days = 19)
@raghumb
raghumb / .py
Created August 10, 2019 14:22
Line Plot
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
weight_kg = np.random.rand(30)
weight_pound = weight_kg * 2.2
lines = plt.plot(weight_kg,weight_pound)
@raghumb
raghumb / .py
Created August 10, 2019 14:16
Scatter Plot
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# Dataframe with random integers 1-100 for Age
age = pd.DataFrame(np.random.randint(1,60,size=(20, 1)), columns=list('A'))
# Dataframe with log values (salary)
salary = np.log10(age['A'])
@raghumb
raghumb / .py
Created August 6, 2019 14:28
Replace NaN in Dataframe
# All columns will be filled with NaN, replace NaN with zero
df = df.fillna(0)
print df
@raghumb
raghumb / .py
Created August 6, 2019 14:23
Create dataframe with index
# Create dataframe with date as index
# end date
end_date = dt.datetime(2018, 1, 1)
# start date is
start_date = end_date - timedelta(days = 5)
dates = pd.date_range(start_date, end_date)
columns = ['Defects','tasks']
# Create Dataframe
df = pd.DataFrame(index=dates, columns=columns)
@raghumb
raghumb / .py
Created August 6, 2019 14:19
Access data by slicing
arr = np.array([[5, 2, 3, 2], [5, 1, 3, 6],[5, 1, 3, 2]])
# Create Dataframe from Numpy Array
df1 = pd.DataFrame(arr)
# Retrieve first two rows and last two columns
df2 = df1.iloc[0:2,1:3]
print df2
@raghumb
raghumb / .py
Last active August 6, 2019 14:15
Access Data in Dataframe
print 'loop using ix - deprecated'
for i in range(df1.size):
val = df1.ix[i]
print val
print 'loop using iloc'
for i in range(df1.size):
val = df1.iloc[i]
@raghumb
raghumb / .py
Created August 6, 2019 13:59
Creation of Dataframe
import numpy as np
import pandas as pd
import datetime as dt
from datetime import timedelta
a = np.array([100,100,1000,0,0])
# Create Dataframe from Numpy Array
df1 = pd.DataFrame(a)