I have two lists, both have the same numer of elements (48 each). I want to create a dataframe that has one of the lists as the columns, and the other list as the values for said columns. Like the following example:
list_1 = ["A", "B", "C", "D", "E"]
list_2 = [1, 2, 3, 4, 5]
I want the resulting dataframe to be like this:
A | B | C | D | E |
---|---|---|---|---|
1 | 2 | 3 | 4 | 5 |
What am I missing? Is there a better/simpler way to do this?
I've tried using pandas:
dataframe = pd.DataFrame(data=data, columns=fields)
But I get the following error:
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[83], line 1
----> 1 dataframe_maybe = pd.DataFrame(data=data, columns=fields)
3 dataframe_maybe
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\core\frame.py:762, in DataFrame.__init__(self, data, index, columns, dtype, copy)
754 mgr = arrays_to_mgr(
755 arrays,
756 columns,
(...)
759 typ=manager,
760 )
761 else:
--> 762 mgr = ndarray_to_mgr(
763 data,
764 index,
765 columns,
766 dtype=dtype,
767 copy=copy,
768 typ=manager,
769 )
770 else:
771 mgr = dict_to_mgr(
772 {},
...
418 passed = values.shape
419 implied = (len(index), len(columns))
--> 420 raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (48, 1), indices imply (48, 48)