## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Nov 18 22:16
athossampayo edited #485
• Nov 18 22:15
athossampayo edited #486
• Nov 16 01:06
gurupratap-matharu commented #483
• Nov 15 04:41
davidwagner opened #491
• Nov 14 22:41
davidwagner commented #482
• Nov 14 22:41
davidwagner commented #483
• Nov 10 20:38
mycarta commented #386
• Nov 10 20:37
mycarta commented #386
• Nov 10 20:33
mycarta commented #386
• Nov 10 20:26
mycarta commented #386
• Nov 10 20:25
mycarta commented #386
• Nov 10 20:25
mycarta commented #386
• Nov 08 19:00
slim-builder edited #488
• Nov 08 19:00
slim-builder edited #489
• Nov 08 18:59
slim-builder opened #490
• Nov 08 07:07
coveralls commented #489
• Nov 08 07:06
coveralls commented #488
• Nov 08 07:03
slim-builder opened #489
• Nov 08 07:01
slim-builder opened #488
• Oct 28 20:24
Yanay1 opened #487
Carl Boettiger
@cboettig
@choldgraf @SamLau95 Hmm, somehow I can no longer do an apply with a function that takes multiple arguments:
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'])
Error is:

---------------------------------------------------------------------------
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'
Sam Lau
@SamLau95
looks like you might have an old version of the package @cboettig
do you have 0.3.dev21?
Chris Holdgraf
@choldgraf
I can confirm that @cboettig's code works on the latest version for me
Chris Holdgraf
@choldgraf
Also - quick quibble, but I often forget to open this package with python 3 sourced, and the error message you get for doing so is a bit cryptic (it just throws an import error)

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?

Sam Lau
@SamLau95
ah, that’s a good idea
Carl Boettiger
@cboettig
@SamLau95 yup, running on ds8.berkeley.edu and it says '0.3.dev21'
Chris Holdgraf
@choldgraf
@SamLau95 want me to make a PR?
Carl Boettiger
@cboettig
It's very strange. I have in my git history successful runs of the notebook with the very same code that works with multiple columns, so I'm not sure why it is failing for me now.
Chris Holdgraf
@choldgraf
hmm, that is weird - and it works for me
problem is I can't really debug it w/o the code breaking for me
maybe just to be sure you can pull the latest changes from the git repo
Sam Lau
@SamLau95
@choldgraf that’d be great
Carl Boettiger
@cboettig
Chris Holdgraf
@choldgraf
@SamLau95 hrmmm, actually it might be more complicated
because it looks like some of the changes actually result in a syntaxerror in 2.7
so it won't get to the point that it's running any code
perhaps a better option would be to prevent it from installing on any versions of python < 3.0?
Sam Lau
@SamLau95
ah i see
would you like to look into that?
if not, feel free to make an issue
Chris Holdgraf
@choldgraf
@cboettig so it looks like the problem is that the function is passing a list of column names to the table. E.g., this returns the same error you get:
t[['letter', 'count', 'points']]
and it looks like that function has indeed been updated. Here's the new code for it: np.array([fn(*[self.take(i)[col][0] for col in column_label]) for i in range(self.num_rows)])
note that there is another 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
so try pulling and it should work
Carl Boettiger
@cboettig
interesting... so somehow I am running an old version of datascience even though it says 0.3.dev21 ?
I'm running this on ds8.berkeley.edu, so I have no ability to install there, but let me try locally. What version are you on?
Chris Holdgraf
@choldgraf
ah interesting
same version
but w/o knowing much about how the repo is organized, that's probably just the current dev branch
and presumably the version of that code being used in ds8 is a few commits behind the branch on github
Carl Boettiger
@cboettig
maybe version number didn't get bumped;
right.
um, so can you reproduce the error on your ds8.berkeley.edu account?
(and I'll try pulling and installing locally)
Chris Holdgraf
@choldgraf
I.......haven't figured that out yet :)
Carl Boettiger
@cboettig
Chris Holdgraf
@choldgraf
ooo it works
Carl Boettiger
@cboettig
nice
Sam Lau
@SamLau95
oh, you know what?
it’s possible that we haven’t pushed a new version to the servers
i mean
we haven’t incremented the version number after making that change
Carl Boettiger
@cboettig
right
Sam Lau
@SamLau95
blah, that’s a pain
maybe there’s a way to locally install the datascience package from the github repo on ds8
Chris Holdgraf
@choldgraf
yeah I get the error on the ds8 servers