As a data scientist working with large datasets in the USA, I often need to transform data structures for efficient processing and analysis. One common task is converting a NumPy array to a tuple or a list of tuples. In this tutorial, I will explain how to convert an array to a tuple in Python using different methods.
Understanding Arrays and Tuples in Python
Before diving into the conversion process, let me explain to you what are arrays and tuples in Python.
What is an Array?
In Python, an array is a data structure provided by the NumPy library. NumPy arrays are homogeneous, meaning they can only contain elements of the same data type. They are efficient for numerical computations and are widely used in scientific computing and data analysis.
What is a Tuple?
A tuple is a built-in data structure in Python that is an ordered, immutable collection of elements. Tuples can contain elements of different data types and are defined using parentheses (). Once created, the elements of a tuple cannot be modified.
Convert an Array to a Tuple in Python
Now, let me show you different methods of converting an array to a tuple in Python with examples.
Method 1: Using the tuple() Function
The simplest way to convert an array to a tuple is by using the built-in tuple() function in Python. This function takes an iterable (such as an array) as an argument and returns a new tuple containing the elements of the iterable.
Here’s an example:
import numpy as np
# Create a NumPy array
employees = np.array(["John", "Emily", "Michael", "Amanda"])
# Convert the array to a tuple
employee_tuple = tuple(employees.tolist())
print(employee_tuple)Output:
('John', 'Emily', 'Michael', 'Amanda')In this example, we have an array employees containing employee names. By passing the array to the tuple() function, we convert it to a tuple employee_tuple.
Here is the exact output in the screenshot below:

Check out Get the First Element of a Tuple in Python
Method 2: Using the tolist() Method and tuple() Function
Another approach to convert an array to a tuple in Python is by first converting the array to a list using the tolist() method and then converting the list to a tuple using the tuple() function.
Here’s an example:
import numpy as np
# Create a NumPy array
sales_data = np.array([1000, 1500, 2000, 1800, 2200])
# Convert the array to a list
sales_list = sales_data.tolist()
# Convert the list to a tuple
sales_tuple = tuple(sales_list)
print(sales_tuple)Output:
(1000, 1500, 2000, 1800, 2200)In this example, we have an array sales_data containing sales figures. We first convert the array to a list using the tolist() method and then convert the resulting list to a tuple using the tuple() function.
You can see the output in the screenshot below after I executed the above Python code using VS code.

Read Access Tuple Elements in Python
Method 3: Using List Comprehension and tuple() Function
List comprehension is another way to create lists based on existing iterables. We can combine list comprehension with the tuple() function to convert an array to a tuple. Let me show you an example.
Here’s an example:
import numpy as np
# Create a NumPy array
cities = np.array(["New York", "Los Angeles", "Chicago", "Houston"])
# Convert the array to a tuple using list comprehension
city_tuple = tuple([city for city in cities])
print(city_tuple)Output:
('New York', 'Los Angeles', 'Chicago', 'Houston')In this example, we have an array cities containing city names. We use list comprehension to create a list of cities and then convert that list to a tuple using the tuple() function.
Read How to Iterate Through Tuples in Python?
Convert a 2D Array to a Tuple of Tuples
When working with multidimensional arrays, you may need to convert a 2D array to a tuple of tuples. Here’s how you can achieve that:
import numpy as np
# Create a 2D NumPy array
student_scores = np.array([[85, 92, 88], [78, 90, 85], [92, 95, 93]])
# Convert the 2D array to a tuple of tuples using the map() function
student_scores_tuple = tuple(map(tuple, student_scores))
print(student_scores_tuple)Output:
((85, 92, 88), (78, 90, 85), (92, 95, 93))In this example, we have a 2D array student_scores representing the scores of students in different subjects. We use the map() function along with the tuple() function to convert each row of the 2D array into a tuple. Finally, we convert the resulting map object to a tuple using the tuple() function.
Check out How to Use Python Array Index -1 in Python
Conclusion
In this tutorial, we explored different methods to convert an array to a tuple in Python. Whether you’re working with 1D arrays or 2D arrays, you can use the tuple() function, tolist() method, list comprehension, or the map() function. I have also explained how to convert a 2D array to a tuple of tuples in Python.
I hope this tutorial has helped you understand how to convert arrays to tuples in Python.
You may also like:
- Append Elements to a Tuple in Python
- Return a Tuple in Python
- Sort by the Second Element in a Tuple in Python
- How to Sort a Tuple in Python?

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.