Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Sep 22, 2020

This PR proposes DataFrame.lookup.

>>> kdf = ks.DataFrame({'A': [3, 4, 5, 6, 7],
...                     'B': [10.0, 20.0, 30.0, 40.0, 50.0],
...                     'C': ['a', 'b', 'c', 'd', 'e']})
>>> kdf
   A     B  C
0  3  10.0  a
1  4  20.0  b
2  5  30.0  c
3  6  40.0  d
4  7  50.0  e

>>> kdf.lookup([0], ["C"])
array(['a'], dtype=object)

>>> kdf.lookup([2, 3], ["A", "B"])
array([ 5., 40.])

@itholic
Copy link
Contributor Author

itholic commented Sep 24, 2020

Thanks, @HyukjinKwon

@itholic
Copy link
Contributor Author

itholic commented Sep 26, 2020

Thanks, @ueshin

raise ValueError("Row labels must have same size as column labels")
lookups = [
self.loc[row_label, col_label]
for row_label, col_label in zip(row_labels, col_labels)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we launch jobs as many as labels?

self.loc[row_label, col_label] for row_label, col_label in zip(row_labels, col_labels)
]
return Series(lookups).to_numpy()
return np.asarray(pd.Series(lookups))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why did we change it to np.asarray(pd.Series(lookups))?

@xinrong-meng
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants