Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 可以更改牵牛星或熊猫上的日期语言吗?_Python_Pandas_Altair - Fatal编程技术网

Python 可以更改牵牛星或熊猫上的日期语言吗?

Python 可以更改牵牛星或熊猫上的日期语言吗?,python,pandas,altair,Python,Pandas,Altair,我不知道这个任务是否可以用牵牛星或熊猫来完成,但我正在寻找文档来更改我的图表的日期语言 这是我的密码: import pandas as pd import altair as alt from datetime import datetime, timedelta url = 'https://raw.githubusercontent.com/mariorz/covid19-mx-time-series/master/data/covid19_confirmed_mx.csv' df =

我不知道这个任务是否可以用牵牛星或熊猫来完成,但我正在寻找文档来更改我的图表的日期语言

这是我的密码:

import pandas as pd
import altair as alt
from datetime import datetime, timedelta

url = 'https://raw.githubusercontent.com/mariorz/covid19-mx-time-series/master/data/covid19_confirmed_mx.csv'
df = pd.read_csv(url, index_col=0)
#df = pd.read_csv(url)

df = df.loc['Colima','18-03-2020':'18-11-2020']
df = pd.DataFrame(df)
df.index = pd.to_datetime(df.index, format='%d-%m-%Y')

%run urban_theme.py

alt.Chart(df.reset_index()).mark_line().encode(
    alt.X('index:T', title = " "),
    alt.Y('Colima:Q', title = " "),
).properties(
    title = "Casos acumulados",
)

输出:


目前还没有很好的文档记录,但中有一些相关信息

您可以为图表设置西班牙语时间格式区域设置,如下所示:

作为pd进口熊猫 将牵牛星导入为alt 从datetime导入datetime,timedelta 从urllib导入请求 导入json 获取并启用西班牙语时间格式区域设置。 带request.urlopen'https://raw.githubusercontent.com/d3/d3-time-format/master/locale/es-ES.json“作为f: es_time_format=json.loadf alt.renderers.set_embed_options timeformatLocale=es_time_format url='1〕https://raw.githubusercontent.com/mariorz/covid19-mx-time-series/master/data/covid19_confirmed_mx.csv' df=pd.read\u csvurl,index\u col=0 df=pd.read\u csvurl df=df.loc['Colima','18-03-2020':'18-11-2020'] df=pd.DataFramedf df.index=pd.to_datetimedf.index,格式=“%d-%m-%Y” alt.Chartdf.reset_index.mark_line.encode alt.X'index:T',title=, alt.Y'Colima:Q',title=, .物业 title=Casos acumulados, 宽度=800
目前还没有很好的文档记录,但中有一些相关信息

您可以为图表设置西班牙语时间格式区域设置,如下所示:

作为pd进口熊猫 将牵牛星导入为alt 从datetime导入datetime,timedelta 从urllib导入请求 导入json 获取并启用西班牙语时间格式区域设置。 带request.urlopen'https://raw.githubusercontent.com/d3/d3-time-format/master/locale/es-ES.json“作为f: es_time_format=json.loadf alt.renderers.set_embed_options timeformatLocale=es_time_format url='1〕https://raw.githubusercontent.com/mariorz/covid19-mx-time-series/master/data/covid19_confirmed_mx.csv' df=pd.read\u csvurl,index\u col=0 df=pd.read\u csvurl df=df.loc['Colima','18-03-2020':'18-11-2020'] df=pd.DataFramedf df.index=pd.to_datetimedf.index,格式=“%d-%m-%Y” alt.Chartdf.reset_index.mark_line.encode alt.X'index:T',title=, alt.Y'Colima:Q',title=, .物业 title=Casos acumulados, 宽度=800 您可以尝试使用locale包并在导入后立即运行locale.setLocaleScale.LC_ALL、“es_es.utf8”。您可以尝试使用locale包并在导入后立即运行locale.setLocaleScale.LC_ALL、“es_es.utf8”