• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: ‘Columns must be same length as key’ trying to populate two columns in pandas

Resolved: ‘Columns must be same length as key’ trying to populate two columns in pandas

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

This pandas code works fine:
However if I want to return two values and update two columns it throws an error:
throws: ValueError: Columns must be same length as key
How to fix this? Note that I need to use apply

Answer:

If you absolutely need to use apply, you can make the return value as a series (But try to use @BENY’s answer):
Output:

If you have better answer, please add a comment about this, thank you!

pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.