Python Forum
valueError: expected 2d, got 1d instead
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
valueError: expected 2d, got 1d instead
#2
As per the error message, data.wgt is a pandas.Series object. You can get the data in a numpy array, which has the 'reshape' method, by accessing the 'values' attribute.
data.wgt.values.reshape(-1, 1)
A quick look at the Pandas docs point towards using 'to_numpy()' instead
data.wgt.to_numpy().reshape(-1, 1)
Reply


Messages In This Thread
RE: valueError: expected 2d, got 1d instead - by boring_accountant - Aug-16-2019, 02:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long long' MaJeFi 2 12,530 Mar-20-2019, 06:00 AM
Last Post: MaJeFi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020