w3resource

NumPy Interoperability Exercises, Practice, Solutions

NumPy Interoperability Exercises [ 20 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

1. Write a NumPy program to convert a Python list to a NumPy array and print the array.
Click me to see the sample solution

2. Write a NumPy program to convert a NumPy array to a native Python list and print the list.
Click me to see the sample solution

3. Write a NumPy program to convert a Python tuple to a NumPy array and print the array.
Click me to see the sample solution

4. Write a NumPy program to convert a NumPy array to a Python tuple and print the tuple.
Click me to see the sample solution

5. Write a NumPy program to convert a Pandas DataFrame to a NumPy array and print the array.
Click me to see the sample solution

6. Write a NumPy program to convert a NumPy array to a Pandas DataFrame and print the DataFrame.
Click me to see the sample solution

7. Write a NumPy program to convert a dictionary with numeric values to a NumPy array and print the array.
Click me to see the sample solution

8. Write a NumPy program to convert a NumPy array to a dictionary with indices as keys and array elements as values.
Click me to see the sample solution

9. Write a NumPy program to convert a nested Python list to a 2D NumPy array and print the array.
Click me to see the sample solution

10. Write a NumPy program to convert a 2D NumPy array to a nested Python list and print the list.
Click me to see the sample solution

11. Write a NumPy program to convert a Pandas Series to a NumPy array and print the array.
Click me to see the sample solution

12. Write a NumPy program to convert a NumPy array to a Pandas Series and print the Series.
Click me to see the sample solution

13. Write a NumPy program to create a Pandas DataFrame, convert it to a NumPy array, and then convert it back to a DataFrame.
Click me to see the sample solution

14. Write a NumPy program to save a NumPy array to a CSV file and verify the contents by reading the file.
Click me to see the sample solution

15. Write a NumPy program to read a CSV file into a NumPy array and print the array.
Click me to see the sample solution

16. Write a NumPy program to convert a 3D NumPy array to a list of lists of lists and print the result.
Click me to see the sample solution

17. Write a NumPy program to convert a list of lists of lists to a 3D NumPy array and print the array.
Click me to see the sample solution

18. Write a NumPy program to convert a Pandas DataFrame with mixed data types (numerics and strings) to a NumPy array.
Click me to see the sample solution

19. Write a NumPy program to combine a NumPy array and a Pandas DataFrame into a single DataFrame and print it.
Click me to see the sample solution

20. Write a NumPy program to append a NumPy array to a Python list and print the result.
Click me to see the sample solution

Python-Numpy Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/numpy/python-numpy-interoperability.php