I have a dataframe DF
:
Data1 Data2
2022/7/8 3 3
2022/7/7 4 2
2022/7/6 5 1
2022/7/5 6 3
2022/7/4 7 2
doing the following :
sns.lineplot(x=DF.index ,y=DF["Data1"],ax=Myax)
throw the error :
ValueError: Data must be 1-dimensional
what am I doing wrong there ?
Below is the requested output :
{('USGG10YR Index', 'PX_LAST'): {datetime.date(2018, 12, 31): 2.6842, datetime.date(2019, 1, 1): 2.6842, datetime.date(2019, 1, 2): 2.6204, datetime.date(2019, 1, 3): 2.5535, datetime.date(2019, 1, 4): 2.6677}, ('GTFRF10YR Corp', 'PX_LAST'): {datetime.date(2018, 12, 31): 0.705, datetime.date(2019, 1, 1): 0.705, datetime.date(2019, 1, 2): 0.648, datetime.date(2019, 1, 3): 0.651, datetime.date(2019, 1, 4): 0.697}, ('GTDEM10YR Corp', 'PX_LAST'): {datetime.date(2018, 12, 31): 0.239, datetime.date(2019, 1, 1): 0.239, datetime.date(2019, 1, 2): 0.164, datetime.date(2019, 1, 3): 0.151, datetime.date(2019, 1, 4): 0.206}, ('GTITLII10Y Govt', 'PX_LAST'): {datetime.date(2018, 12, 31): 1.811, datetime.date(2019, 1, 1): 1.811, datetime.date(2019, 1, 2): 1.782, datetime.date(2019, 1, 3): 1.947, datetime.date(2019, 1, 4): 1.974}}
CodePudding user response:
Your columns are a MultiIndex
, so reference accordingly:
sns.lineplot(
x=TenYearGovYieldHist.index,
y=TenYearGovYieldHistf[('USGG10YR Index', 'PX_LAST')],
ax=Myax
)
Or using droplevel
:
sns.lineplot(
x=TenYearGovYieldHist.index,
y=TenYearGovYieldHist.droplevel(1, axis=1)['USGG10YR Index'],
ax=Myax
)