0

I have two numpy arrays with the following dimensions

Array1

(3,6)

Array2

(3,5)

Can I concatenate this into a pandas df with dimensions (2,3, ) i.e third dimensional being varied? So, if I query the first row of the resulting DF, I get a numpy array of dimension (3,6) and if I query the second row of the resulting DF, I get a numpy array of dimensions (3,5)

In both cases the one of the dimensions of the input array is constant.

Thanks!

Yeheshuah
  • 1,216
  • 1
  • 13
  • 28
FlyingPickle
  • 1,047
  • 1
  • 9
  • 19
  • This is simply a matter of storing the NumPy array into the data frame's only column. Where are you having trouble? – Prune Mar 18 '20 at 00:06
  • I have created a DF and trying an append to it ````DF.append(Array1)```` but it gives me ````cannot concatenate object of type ''; only Series and DataFrame objs are valid```` – FlyingPickle Mar 18 '20 at 00:21
  • Convert it to a series, then? – Prune Mar 18 '20 at 00:23
  • Converting it to a series seems to not preserve the dimensions...so the behaviour of pandas is a bit confusing here... – FlyingPickle Mar 18 '20 at 00:46
  • 1
    https://stackoverflow.com/questions/45548426/store-numpy-array-in-cells-of-a-pandas-dataframe - this link helped me sort out my confusion. Thanks! – FlyingPickle Mar 18 '20 at 01:00

0 Answers0