'Map Reduce Python 3.x- TypeError: unsupported operand type(s) for |: 'str' and 'function'
Taking a data science class and this is the textbook example, but I can't translate it into python 3.x.
import sys
def mapper():
for line in sys.stdin:
data = line.split(',')
print (data[1] + ',' + data[2])
def reduce():
high = 0
for line in sys.stdin:
data = line.split(',')
close = float(data[1].rstrip())
if (close > high):
high = close
date = data[0]
print(date + ',' + str(high))
path = r'C:\Users\kingj\Downloads\stocks.csv'
mapper < path | reduce
I get this error:
----> 2 mapper < path | reduce
TypeError: unsupported operand type(s) for |: 'str' and 'function'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
