Skip to content

Instantly share code, notes, and snippets.

@raghumb
raghumb / .py
Last active August 4, 2019 15:07
Other Operations
# Find index of max value excluding Nan values
arr = np.array([[5, 2, 3, 2], [5, 1, 3, 6],[5, 1, 3, 2]])
print arr
max = np.nanargmax(arr)
print max
max = np.amax(arr)
print 'Maximum value in array'
print max
@raghumb
raghumb / .py
Last active August 4, 2019 15:07
Array Data Retrieval
arr = np.array([[5, 2, 3, 2], [5, 1, 3, 6],[5, 1, 3, 2]])
print arr
# Get all rows of 4th column
print '4th column'
print arr[:, 3]
# Get all columns of 2nd row
print '2nd row'
print arr[1,:]
@raghumb
raghumb / .py
Created August 4, 2019 14:33
Array Comparison
# Create Array with three rows
arr = np.array([[5, 2, 3, 2], [5, 1, 3, 6],[5, 1, 3, 2]])
print arr
# Compare all rows with first row: (returns an array with boolean for each row)
condition = (arr == arr[0])
print condition
# Compare if all elements in array are True (We will do this for first row of condition array)
if condition[0].all() == True:
@raghumb
raghumb / .py
Last active August 4, 2019 14:21
Array Operations
# Create an Array
arr = np.array([[5, 7, -1, 0]])
print arr
# Get number of rows
row = arr.shape[0]
print row
# Get number of columns
col = arr.shape[1]
data "aws_iam_policy_document" "my-sqs-policy" {
statement {
actions = ["sqs:ReceiveMessage"]
resources = ["arn:aws:sqs:us-east-2:...."]
}
}
resource "aws_iam_policy" "my-sqs-policy" {
policy = "${data.aws_iam_policy_document.my-sqs-policy.json}"
resource "aws_vpc" "myvpc" {
cidr_block = "${var.vpc_cidr_range}"
tags = {
Name = "demovpc"
}
}
data "aws_vpc" "myvpc" {
tags = {
Name = "demovpc"
}
}
resource "aws_subnet" "demosubnet" {
variable "vpc_cidr_range"{
type = "string"
default= "10.0.0.0/16"
}
variable "subnet_cidr_range"{
type = "string"
default= "10.0.0.0/24"
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "my-vm-automated" {
ami = "ami-a4c7edb2"
instance_type = "t2.micro"
key_name="myec2keypair"
tags {
Name = "my-vm-automated"
}
}