In [455]: x = np.array([np.array(['0 <= ... < 200 DM', '< 0 DM', 'no checking account'], dtype=object),
...:
...: np.array(['critical account/ other credits existing (not at this bank)',
...: 'existing credits paid back duly till now'], dtype=object),
...: np.array(['(vacation - does not exist?)', 'domestic appliances'],
...: dtype=object)], dtype=object)
In [456]: x
Out[456]:
array([array(['0 <= ... < 200 DM', '< 0 DM', 'no checking account'], dtype=object),
array(['critical account/ other credits existing (not at this bank)',
'existing credits paid back duly till now'], dtype=object),
array(['(vacation - does not exist?)', 'domestic appliances'],
dtype=object)], dtype=object)
In [457]: x.shape
Out[457]: (3,)
In [458]: [i.shape for i in x]
Out[458]: [(3,), (2,), (2,)]
x
- это одномерный массив с 3 элементами. Эти элементы сами по себе являются массивами различной формы.
Один из способов сгладить это:
In [459]: np.hstack(x)
Out[459]:
array(['0 <= ... < 200 DM', '< 0 DM', 'no checking account',
'critical account/ other credits existing (not at this bank)',
'existing credits paid back duly till now',
'(vacation - does not exist?)', 'domestic appliances'],
dtype=object)
In [460]: _.shape
Out[460]: (7,)