Skip to content

BUG: Index.union cannot handle array-likes #10149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sinhrks opened this issue May 15, 2015 · 0 comments · Fixed by #10157
Closed

BUG: Index.union cannot handle array-likes #10149

sinhrks opened this issue May 15, 2015 · 0 comments · Fixed by #10157
Labels
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented May 15, 2015

Though API doc says Index.union can accept Index or array-like, it raises errors.

import numpy as np
import pandas as pd
idx = pd.Index([1, 2, 3])

idx.union([2, 3, 4])
# AttributeError: 'list' object has no attribute 'dtype'

idx.union(pd.Series([2, 3, 4]))
# AttributeError: 'Series' object has no attribute 'is_monotonic'

idx.union(np.array([2, 3, 4]))
# AttributeError: 'numpy.ndarray' object has no attribute 'is_monotonic'

NOTE: intersection looks OK.

idx.intersection([2, 3, 4])
# Int64Index([2, 3], dtype='int64')

idx.intersection(pd.Series([2, 3, 4]))
# Int64Index([2, 3], dtype='int64')

idx.union([2, 3, 4])
# Int64Index([2, 3], dtype='int64')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants