How to make custom dtype in NumPy array?

I’m working on a data science project in which right now my main task is to create custom datatypes with specific bytes of memory. I used NumPy for it and developed a code that is below:

I want to know if any other alternative methods and logic are there available for doing it because my method doesn’t look very efficient. If yes, share them with me. I will appreciate your efforts.