I have the following DF :
A Index B Index C Index D Index
PX_LAST PX_LAST PX_LAST PX_LAST
2021-12-31 1.5101 0.195 -2.101 -0.509
2022-01-03 1.628 0.244 -2.032 -0.468
2022-01-04 1.6473 0.233 -2.074 -0.511
2022-01-05 1.7052 0.229 -2.045 -0.468
2022-01-06 1.7211 0.261 -1.965 -0.37
2022-01-07 1.762 0.285 -1.97 -0.338
2022-01-10 1.7603 0.284 -1.964 -0.361
2022-01-11 1.7357 0.347 -1.961 -0.348
2022-01-12 1.7428 0.321 -1.995 -0.384
2022-01-13 1.7041 0.288 -1.993 -0.394
2022-01-14 1.7841 0.332 -1.959 -0.352
2022-01-17 1.7841 0.355 -1.948 -0.339
2022-01-18 1.8735 0.368 -1.941 -0.311
2022-01-19 1.8646 0.38 -1.924 -0.283
2022-01-20 1.804 0.363 -1.918 -0.306
2022-01-21 1.7581 0.332 -1.925 -0.291
2022-01-24 1.7706 0.305 -1.959 -0.28
2022-01-25 1.7689 0.331 -1.954 -0.294
2022-01-26 1.8637 0.336 -1.951 -0.265
2022-01-27 1.7994 0.344 -1.943 -0.33
2022-01-28 1.7694 0.367 -1.95 -0.365
2022-01-31 1.7767 0.424 -1.969 -0.402
When I try to plot it doing :
df.plot(x=df.index,y=["A Index","B Index","X Index","D Index"])
it does throw the following issue
KeyError: "Index([2021-12-31, 2022-01-03, 2022-01-04, 2022-01-05, 2022-01-06, 2022-01-07,\n 2022-01-10, 2022-01-11, 2022-01-12, 2022-01-13,\n ...\n dtype='object', length=135) not in index"
What are these ‘\n’? How can I plot this DF ?
Many Thanks
>Solution :
The \n are likely just a representation of the newline characters in the error message.
Plotting by index is the default behavior if no x is specified. df.plot(y=["A Index", "B Index"]) gives

