0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

objectのlistの和を取る

Posted at

holoviewsのobjectをlistに収めていきまとめて和ととるとsumを使ったらうまく行かなかったのでメモ

import quandl
import holoviews as hv
hv.extension('bokeh')

curve_lst = []
df = quandl.get("TSE/1321", start='2018-01-01', end='2018-12-31')
curve_lst.append(hv.Curve(df, 'Date', 'Low'))
curve_lst.append(hv.Curve(df, 'Date', 'Low'))
curve_lst.append(hv.Curve(df, 'Date', 'Low'))

sum(curve_lst)

これはerrorになる
TypeError: unsupported operand type(s) for +: 'int' and 'Curve'

import quandl
import holoviews as hv
hv.extension('bokeh')

curve_lst = []
df = quandl.get("TSE/1321", start='2018-01-01', end='2018-12-31')
curve_lst.append(hv.Curve(df, 'Date', 'Low'))
curve_lst.append(hv.Curve(df, 'Date', 'Low'))
curve_lst.append(hv.Curve(df, 'Date', 'Low'))

import functools
functools.reduce(lambda x, y: x+y, curve_lst)

これで動く
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?