letter = ['a', 'b', 'c', 'z']
count = [9, 3, 3, 1]
points = [1, 2, 2, 10]
t = Table([letter, count, points], ['letter', 'count', 'points'])
# Works
t.apply(lambda x: x * x, 'count')
## throws error
t.apply(lambda x, y: x * y, ['count', 'points'])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-8fe518b79c55> in <module>()
7 t.apply(lambda x: x * x, 'count')
8
----> 9 t.apply(lambda x, y: x * y, ['count', 'points'])
10
11 #array([ 9, 6, 6, 10])
/usr/local/lib/python3.4/dist-packages/datascience/tables.py in apply(self, fn, column_label)
447 """Returns an array where fn is applied to each element
448 of a specified column."""
--> 449 return np.array([fn(v) for v in self[column_label]])
450
451 ############
/usr/local/lib/python3.4/dist-packages/datascience/tables.py in __getitem__(self, label)
352
353 def __getitem__(self, label):
--> 354 return self.values(label)
355
356 def __setitem__(self, label, values):
/usr/local/lib/python3.4/dist-packages/datascience/tables.py in values(self, label)
438 An instance of ``numpy.array``.
439 """
--> 440 return self._columns[label]
441
442 def column_index(self, column_label):
TypeError: unhashable type: 'list'
think we could just put:
import sys
if sys.version_info < (3, 0):
raise ValueError('This package requires python >= 3.0')
at the root __init__.py
?
t[['letter', 'count', 'points']]
np.array([fn(*[self.take(i)[col][0] for col in column_label]) for i in range(self.num_rows)])
for
loop: for col in column_label
so now it's passing each column that you give individually, that way it never tries to pass a list
ds8.berkeley.edu
, so I have no ability to install there, but let me try locally. What version are you on?