Solving ValueError: Wrong number of items passed. placement implies … in Python

ValueError: Wrong number of items passed , placement implies … in Python is a Python error which occurs when you pass too many arguments but the method supports only a few arguments.

In this article I am going to solve the error while I try explaining why the error is popping up in the first place, I will also introduce some solutions which worked for other developers and we will see if those solutions can solve the error in your unique situation.

Solving ValueError: Wrong number of items passed. placement implies … in Python

The error happens when you pass too many arguments but the method supports only a few arguments.

The error message you are having should look like the error message bellow.

                                                                       #
KeyError  Traceback (most recent call last)
-> 1945                 return self._engine.get_loc(key)
...
pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)()
          # This item wasn't present, just insert at end
-> 3418             self.insert(len(self.items), item, value)
---> 90                                              len(self.mgr_locs)))
     92     @property
ValueError: Wrong number of items passed 3, placement implies 1
                                                                       #

Bellow I will present multiple solutions some have worked for me and others have worked for other developers.

Solution 1 : use another sub-list

The easiest solution to the issue is to use another sub-list.

You can do that similar to what I did in the code bellow.

                                                                       #
df[['Girls_Names', 'Boys_Names']] = df['Full_col'].str.split(' ', expand = True)
                                                                       #

This solution should work for you, if it does not please try the second solution.

Solution 2 : correct your data

You need to understand very well you are having the error, this is not a bug, this is a problem with your own data.

The error ValueError: Wrong number of items passed 3. placement implies 1 means you are trying to put 3 data boxes lets just call them that for the sake of explaining. into a container that allows only one box.

So, the solution is to format your data properly and realize that one box can only fit in one box.

The error above was hard to deal with, I spent hours looking for a proper solution or set of solutions.

Support me on Kofi if you appreciate the effort, thank you so much.

Summing-up

I hope the solutions have been helpful, I hope you solved the error already, you can support us by donating to our Kofi account, this website is free to use but any help is very appreciated and goes a long way.

I hope my article was helpful in solving this error, errors are part of our journey of coding with Python, keep learning, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/