I have several lists that I’m trying to enter into a data frame:
mydates = [0, 6, 15, 21, 30, 37, 45, 53]
prices = [30.4, 32.5, 31.7, 31.2, 32.7, 34.1, 35.8, 37.8]
mylist = [6.907894736842111, -2.461538461538464, -1.5772870662460567,4.807692307692319,
4.2813455657492305, 4.985337243401747, 5.5865921787709505, -3.9682539682539684]
I enter
df = DataFrame(prices, mylist, index=mydates, columns=['Prices', 'Percentage
s'])
And receive this error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: __init__() got multiple values for keyword argument 'index'
While if I enter this everything works fine.
df = DataFrame(prices, index=mydates, columns=['Prices'])
Could someone please tell me how to fix what’s wrong? .
EDIT:
As Wouter Overmeire pointed out, you can use
DataFrame({'prices': prices, 'mylist': mylist}, index=columnanme)to index by column.