👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
Index.union()
Pandas Index.union()
joins two Index objects and sorts them , if possible. The following function behaves like a standard set union operation. The function can also find a union of categorical data.
Syntax: Index.union (other)
Parameters:
other: Index or array-likeReturns: union: Index
Example # 1: Use Index.union ()
to find the union of two indexes.
# import pandas as pd
import
pandas as pd
# Create first index
idx1
=
pd.Index ([
10
,
20
,
18
,
32
])
# Create second index
idx2
=
pd.Index ([
21
,
10
,
30
,
40
,
50
])
# Print first index
print
(idx1)
# Print the second index
print
(
""
, idx2)
Exit :
Let’s find the union of these two indices
|
Output:
The function found the concatenation of these two indices.
Example # 2: Use Index.union ()
to perform a set join operation on the data of two indexes. Index marks are of string type.
|
Output:
Let’s find the union of these two indexes.
|
Output:
The function returned a new index that contains the result of the union of the idx1 and idx2 sets.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Python | Pandas Index.union (), check other abc Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Python | Pandas Index.union ()
- Deutsch Python | Pandas Index.union ()
- Français Python | Pandas Index.union ()
- Español Python | Pandas Index.union ()
- Türk Python | Pandas Index.union ()
- Русский Python | Pandas Index.union ()
- Português Python | Pandas Index.union ()
- Polski Python | Pandas Index.union ()
- Nederlandse Python | Pandas Index.union ()
- 中文 Python | Pandas Index.union ()
- 한국어 Python | Pandas Index.union ()
- 日本語 Python | Pandas Index.union ()
- हिन्दी Python | Pandas Index.union ()
Berlin | 2023-03-24
Maybe there are another answers? What Python | Pandas Index.union () exactly means?. I just hope that will not emerge anymore
Singapore | 2023-03-24
I was preparing for my coding interview, thanks for clarifying this - Python | Pandas Index.union () in Python is not the simplest one. Will get back tomorrow with feedback
New York | 2023-03-24
Maybe there are another answers? What Python | Pandas Index.union () exactly means?. Will use it in my bachelor thesis