You are on page 1of 5

INSTITUTE OF MANAGEMENT STUDY

Full name: Rohit Manna

Roll no: 19458122005

Registration No: 221941810004

Stream: M.SC (Data Analytics)

Semester: 3rd

Paper Name: Big Data Technology and OLTP Lab

Paper Code: MDS-392


1.Create a NoSQL Database Transport (Brand, Speed, Colour) and insert data
into transport database using NOSQL command. Run the following
Query:

a. To display the vehicles which have a speed greater than 100.

b. To display the vehicles which have a speed equal to 250.

c. To display the vehicles which have a speed lesser than 500 and brand as Benz.

Lets assume we have below data inside collection:-


// Inserting data into the transport collection

"brand": "Toyota",

"speed": 120,

"color": "Blue"

"brand": "Honda",

"speed": 90,

"color": "Red"

"brand": "Benz",

"speed": 250,

"color": "Black"

"brand": "Ford",

"speed": 300,

"color": "Silver"

}
a. To display the vehicles which have a speed greater than 100.

Ans:-
Quary:-

db.transport.find({ "speed": { $gt: 100 } })

b. To display the vehicles which have a speed equal to 250.

Quary:-

db.transport.find({ "speed": 250 })

c. To display the vehicles which have a speed lesser than 500 and brand as Benz.

Quary:-

db.transport.find({ "speed": { $lt: 500 }, "brand": "Benz" })


2. Find the most frequent value in a NumPy array. Example: array ([1,2,3,4,5,1,2,1,1,1])
Output: 1.

Code:-

import numpy as np

# Create a NumPy array

arr = np.array([1, 2, 3, 4, 5, 1, 2, 1, 1, 1])

# Use the 'numpy.bincount' function to count occurrences of each value

counts = np.bincount(arr)

# Find the value with the highest count

most_frequent_value = np.argmax(counts)

print("Most frequent value:", most_frequent_value)

OutPut:-

3.Write a python program to Remove rows in Numpy array that contains nonnumeric values.

Code:-

import numpy as np

# Create a NumPy array with some non-numeric values

data = np.array([[1, 2, 3],


[4, 5, 6],

[7, 'nun', 9], # Contains a non-numeric value ('A')

['X', 'Y', 'Z'] # Contains all non-numeric values

])

# Function to check if a row contains only numeric values

def is_numeric_row(row):

return np.all(np.char.isnumeric(row))

# Filter the array to keep only rows with numeric values

numeric_rows = data[np.apply_along_axis(is_numeric_row, axis=1, arr=data)]

print("Original array:")

print(data)

print("\nArray after removing rows with non-numeric values:")

print(numeric_rows)

OutPut:-

THE END

You might also like