【发布时间】:2021-01-11 09:57:15
【问题描述】:
提前感谢您的帮助!
我正在尝试在 matplotlib 中创建箱线图,但在尝试添加标签时出现错误。 这是导致错误的代码:
df_selected_station_D.boxplot(column='20 cm', by='Month',figsize=(15,5),grid=True, xlabel = 'x data');
这是它导致的错误:
TypeError: boxplot() got an unexpected keyword argument 'xlabel'
这个错误是什么意思,为什么我会得到它? (完整代码和图片如下)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
raw_data = pd.read_csv('all-deep-soil-temperatures.csv', index_col=1, parse_dates=True)
df_all_stations = raw_data.copy()
df_selected_station = df_all_stations[df_all_stations['Station'] == 'Minot']
df_selected_station.fillna(method = 'ffill', inplace=True);
df_selected_station_D=df_selected_station.resample(rule='D').mean()
df_selected_station_D['Day'] = df_selected_station_D.index.dayofyear
mean=df_selected_station_D.groupby(by='Day').mean()
mean['Day']=mean.index
df_selected_station_D['Month'] = df_selected_station_D.index.month
df_selected_station_D.head()
df_selected_station_D.boxplot(column='20 cm', by='Month',figsize=(15,5),grid=True);
【问题讨论】:
标签: python pandas numpy matplotlib time-series