<jupyter_start><jupyter_text>---title: "Inspecting Your Array"author: "<NAME>"date: 2019-06-09description: "-"type: technical_notedraft: false---<jupyter_code>import numpy as np
# sample array
data = np.full((3, 4), 4)
data<jupyter_output><empty_output><jupyter_text>Array dimensions<jupyter_code>data.shape #3x4<jupyter_output><empty_output><jupyter_text>Length of array<jupyter_code>len(data) # 3 row<jupyter_output><empty_output><jupyter_text>Number of array dimensions<jupyter_code>data.ndim # 2D array<jupyter_output><empty_output><jupyter_text>Number of array elements<jupyter_code>data.size # 3x4 = 12<jupyter_output><empty_output><jupyter_text>Data type of array elements<jupyter_code>data.dtype # return object<jupyter_output><empty_output><jupyter_text>Name of data type<jupyter_code>data.dtype.name # return string<jupyter_output><empty_output><jupyter_text>Convert an array to different type<jupyter_code>data = data.astype(float)
data
data.dtype<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1194331983805668, 'fraction_numerical': 0.019230769230769232, 'mean_word_length': 11.209876543209877, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '296500', 'license': 'MIT', 'n_tokens_mistral': 385, 'n_tokens_neox': 374, 'n_words': 54, 'path': 'docs/python/NumPy/Inspecting-Your-Array.ipynb', 'repo_name': 'mmblack4/mynotes', 'size': '991'}