Python | Pandas Index.union() Last Updated : 22 Sep, 2021 Comments Improve Suggest changes Like Article Like Report Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.union() function form the union of two Index objects and sorts if possible. The function follows behaves like a standard set union operation. The function can also find the union of categorical data. Syntax: Index.union(other)Parameters : other : Index or array-likeReturns : union : Index Example #1: Use Index.union() function to find the union of two indexes. Python3 # importing pandas as pd import pandas as pd # Creating the first index idx1 = pd.Index([10, 20, 18, 32]) # Creating the second index idx2 = pd.Index([21, 10, 30, 40, 50]) # Print the first Index print(idx1) # Print the second Index print("\n", idx2) Output : Let's find the union of these two indexes Python3 # perform set union of the two indexes idx1.union(idx2) Output : The function has found the union of these two indexes. Example #2: Use Index.union() function to perform set union operation on the given two indexes. Index labels are of string type. Python3 # importing pandas as pd import pandas as pd # Creating the first index idx1 = pd.Index(['Harry', 'Mike', 'Arther', 'Nick'], name ='Student') # Creating the second index idx2 = pd.Index(['Alice', 'Bob', 'Rachel', 'Tyler', 'Louis'], name ='Winners') # Print the first Index print(idx1) # Print the second Index print("\n", idx2) Output : Let's find the union of these two indexes. Python3 # find union of two indexes idx1.union(idx2) Output : The function has returned a new index that contains the result of the set union of the idx1 and idx2. Comment More infoAdvertise with us Next Article Python | Pandas Index.union() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.tolist() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.tolist() function return a list of the values. These are each a scalar ty 1 min read Python | Pandas Index.values Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.values attribute return an array representing the data in the given Index object. Syntax: Index.values Parameter : None Returns : an a 2 min read Python | Pandas Index.summary() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.summary() function return a summarized representation of the Index. This 2 min read Python | Pandas Index.to_series() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.to_series() function create a Series with both index and values equal to 2 min read Python | Pandas Index.where Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.where function return an Index of same shape as self and whose corresponding entries are from self where cond is True and otherwise ar 2 min read Python | Pandas Index.shape Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.shape attribute return a tuple of the shape of the underlying data in the given Index object. Syntax: Index.shape Parameter : None Ret 2 min read Python | Pandas Index.to_frame() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.to_frame() function create a dataFrame from the given index with a column 2 min read Python | Pandas Index.all() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.all() function checks if all the elements in the index are true or not. I 2 min read Python | Pandas Index.any() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.any() function checks if any of the elements in the index are true or not 2 min read Python | Pandas Index.isin() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.isin() function return a boolean array where the index values are in valu 2 min read Like