0% found this document useful (0 votes)
26 views2 pages

Bda Practical 1

BIG DATA ANALYST

Uploaded by

varmavikash990
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Bda Practical 1

BIG DATA ANALYST

Uploaded by

varmavikash990
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Faculty of Engineering & Technology

Big Data Analytics (203105348)


B. Tech CSE 4rd Year 7th Semester

PRACTICAL 1

Aim: To understand the overall programming architecture using Map Reduce


API.

The MapReduce task is mainly divided into two phases Map Phase and Reduce Phase.

1. map(), filter(), and reduce() in Python.


2. These functions are most commonly used with Lambda function.

1. map():

"A map function executes certain instructions or functionality provided to it on every item of
an iterable."The iterable could be a list, tuple, set, etc.

• SYNTAX:

map(function, iterable)

• Example:

items = [1, 2, 3, 4, 5]
a=list(map((lambda x: x **3), items))
print(a)

• Output:

The map() function passes each element in the list to a lambda function and returns the
mapped object.

2. filter():

"A filter function in Python tests a specific user-defined condition for a function and returns
an iterable for the elements and values that satisfy the condition or, in other words, return
true."

• SYNTAX:

filter(function, iterable)

• Example:
a = [1,2,3,4,5,6]
Enrollment No.: 2203051057106
Roll Number: 68
Div: 7A9(CSE)
Faculty of Engineering & Technology
Big Data Analytics (203105348)
B. Tech CSE 4rd Year 7th Semester
b = [2,5,0,7,3]
c= list(filter(lambda x: x in a, b))
print(c)

• Output:

3. reduce():

"Reduce functions apply a function to every item of an iterable and gives back a single value
as a resultant".

we have to import the reduce function from functools module using the statement

• SYNTAX:

reduce(function, iterable)

• Example:

from functools import reduce


a=reduce( (lambda x, y: x * y), [1, 2, 3, 4] )
print(a)

• Output:

Enrollment No.: 2203051057106


Roll Number: 68
Div: 7A9(CSE)

You might also like