У меня есть 2 * 4 коробки, каждый из которых содержит 21 коробку.Для каждого из них я хотел бы построить последнее значение в каждом столбце данных.
![enter image description here](https://i.stack.imgur.com/yPu4q.png)
Более детально рассмотрим один из них: ![enter image description here](https://i.stack.imgur.com/ndmPV.png)
fig,axes = plt.subplots(2, 4, figsize = (40,20))
deltas = np.arange(0.0, 1.05, 0.05)
l_stringss = [['call_this_month_', 'call_next_month_', 'call_this_quarter_','call_next_quarter_'],
['put_this_month_','put_next_month_', 'put_this_quarter_', 'put_next_quarter_']]
for l_strings in l_stringss:
i = l_stringss.index(l_strings)
for string in l_strings:
j = l_strings.index(string)
vol_dict = {}
for delta in deltas:
option = pd.read_csv(string + str(delta) + '.csv')
vol_dict[delta] = option.vol.values
vols = pd.DataFrame(dict([(k,pd.Series(v)) for k, v in vol_dict.items()]))
if 'call' in string:
order = deltas
elif 'put' in string:
order = deltas[::-1]
sns.boxplot(data = vols, order = order, ax = axes[i][j]).set_title(string[:-1])
пример входных данных:
date id strike vol delta
0 2015-03-24 10000097 2.8 0.441618 0.005203
1 2015-03-25 10000097 2.8 0.013609 0.008506
2 2015-04-20 10000175 3.4 0.564792 0.015379
3 2015-04-21 10000167 3.3 0.366533 0.005255
4 2015-04-22 10000175 3.4 0.003894 0.021423