Recently, I published a small example project to utilize the htm.core AI algorithm by consuming its REST API via C#. As the API also transfers serialized multi-dimensional NumPy arrays, I was looking for an easy way to get them back into C# objects. I’ve tried out a couple of approaches and finally decided on using the NumSharp library, as I wanted a solution that works on multiple platforms.
I find DataCamps’ Data Science Cheat Sheets very useful and was hoping to find something similar for NumSharp. Well, I didn’t, but obviously that gave me a good reason to just compile one myself.
NumPy Cheat Sheet – Python for Data Science April 18, 2017 April 18, 2017 Vik Paruchuri Data Analytics, Libraries, NumPy, Statistics NumPy is the library that gives Python its ability to work with data at speed.
- 2 Python For Data Science Cheat Sheet NumPy Basics Learn Python for Data Science Interactively at www.DataCamp.com NumPy DataCamp Learn Python for Data Science Interactively The NumPy library is the core library for scientific computing in Python. It provides a high-performance multidimensional array.
- NumPy Cheat Sheet: Data Analysis in Python This Python cheat sheet is a quick reference for NumPy beginners. Given the fact that it's one of the fundamental packages for scientific computing, NumPy is one of the packages that you must be able to use and know if you want to do data science with Python.
- NumPy Cheat Sheet for Python. Coding, Data / By Rahman. NumPy is a library for the Python programming language which is used for working with multi-dimensional arrays and matrices. This is very useful in large scientific computing. Because NumPy ndarrays is way faster compared to a regular python list. Arrays are very frequently used in data.
So using the original DataCamps’ NumPy Cheat Sheet as foundation, let me introduce the freshly created NumSharp Cheat Sheet:
As you will notice, some stuff from the original cheat sheet is missing. That’s mainly because not all NumPy functionality has been ported yet. However, if I missed something important, please let me know.
Interactive Notebook
Besides the NumSharp Cheat Sheet itself, I also created a dotnet interactive notebook, which allows you to play around with NumSharp directly in your web-browser. Just click on the binder launch icon below to start it up (might take some time, so please be patient).
Notebook notes
Before you play around with the notebook, please ensure that you always run the top two cells first.
The first cell installs the NumSharp package via NuGet, and the second one makes is available to the other cells.
Output Format
Using the interactive C# notebook, NDArray variables are printed in a tabular, pandas like format, per default.
To mimic the output format of the NumPy Cheat Sheet, just use the ToString() method, as shown above.
Numpy Cheat Sheet 2021
Workarounds
As mentioned earlier, some functionality of NumPy is not ported to NumSharp. The jupyter notebook shows a possible workaround for the element-wise comparison with the < and > operators, for example.
Datacamp Numpy Cheat Sheet
If you are aware of workarounds for any of the other missing functions/methods, please feel free to contribute to the NumSharp Cheat Sheet interactive notebook GitHub project.
That’s it again for now. Have a great time and happy coding!
5