(128, 24, 91) turn numpy array to pd dataframe in python

To convert a numpy array to a pandas dataframe in Python, you can use the pd.DataFrame() function from the pandas library.

First, import the necessary libraries:

main.py
import numpy as np
import pandas as pd
39 chars
3 lines

Next, create your numpy array:

main.py
arr = np.array([(128, 24, 91)])
32 chars
2 lines

Then, convert the numpy array to a pandas dataframe:

main.py
df = pd.DataFrame(arr)
23 chars
2 lines

Here is the complete code:

main.py
import numpy as np
import pandas as pd

arr = np.array([(128, 24, 91)])
df = pd.DataFrame(arr)
95 chars
6 lines

Now, you have successfully converted the numpy array (128, 24, 91) to a pandas DataFrame df.

related categories

gistlibby LogSnag