1

I have a dataframe df with 1 column

inside each row of this column I have a np.array object with 3 elements

Is there a way to unlist this array and create a DataFrame with 3 columns for easy manipulation.

chantal dem
  • 55
  • 1
  • 5

1 Answers1

0

Your question was already asked and answered here:
enter link description here

Anyway, let's say your dataframe looks like this

import pandas as pd, numpy as np
df = pd.DataFrame({'A': [ np.array([1, 2, 3]), np.array([4, 5, 6]), np.array([7, 8, 9])]})
df

enter image description here

Create New dataframe df1, converting column A of original df as a list

df1 = pd.DataFrame(columns = ['A1', 'A2', 'A3'], data = list(df['A']))
df1

enter image description here

Samer Ayoub
  • 981
  • 9
  • 10