【问题标题】:Altair Charts containing Encoding of Special Characters包含特殊字符编码的 Altair 图表
【发布时间】:2022-12-03 18:05:44
【问题描述】:

I am trying to plot a chart from a spreadsheet with this code.

import pandas as pd
import altair as alt
crude_df = pd.read_excel(open(\'PET_CONS_PSUP_DC_NUS_MBBLPD_M.xls\', \'rb\'),
              sheet_name=\'Data 1\',index_col=None, header=2)  

alt.Chart(crude_df.tail(100)).mark_circle().encode(
    x = \'Date\',
    y = r\'U\\.S\\. Product Supplied of Normal Butane (Thousand Barrels per Day)\'
)

I got this part of the code from the Altair Documentation

y = r\'U\\.S\\. Product Supplied of Normal Butane (Thousand Barrels per Day)\'

This is to mitigate the Chart appearing with empty content problem due to presence of special characters in Encodings

But I still get Error.

ValueError: U\\.S\\. Product Supplied of Normal Butane (Thousand Barrels per Day) encoding field is specified without a type; the type cannot be inferred because it does not match any column in the data.

Not sure what I am doing wrong.

    标签: python python-3.x visualization altair


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    相关资源
    最近更新 更多