Array array columns cannot be unified

Asked 2 years ago, Updated 2 years ago, 42 views

The following data columns cannot be unified.Why?

The following df3 data

array([-1, 0, 1, 2, 1, 3, 4, 5, 6, 3, 3, 7, 8, 9]),
list([-1, 10, 11, 10, 12, 13, 14, 15, 13, 16, 17, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, = object])

Here is the coat to arrange the columns of the above data.

Code python

X=sum(df3.tolist(),[])
## Max size
l=max(map(len,X))
## padding
B = np.array (map(lambdax:x+[0]*(l-len(x))), X))

The following error details

AttributeError Traceback (most recent call last)
<ipython-input-13-d279312ff4d1>in<module>
---->1 X = sum (df3.tolist(), [ ])
      2## Max size
      3 l = max (map(len, X))
      4## Padding
      5 B = np.array (map(lambdax:x + [0]*(l-len(x))), X))

AttributeError: 'list' object has no attribute'tolist'

Thank you for your cooperation.

python numpy

2022-09-29 20:27

1 Answers

This has been resolved.
I misunderstood and thought it was an array.It was a list.


2022-09-29 20:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.