Newbie here.
Im trying to learn Python and work with datasets, ive kinda got thrown into the deep end at work. The language is clearly very powerful but very different to anything else ive experienced before.
I need some clarity / help / explanation on the following please.
Partial Algo code
history = data.history(context.stock_list, fields="price", bar_count=300, frequency="1d")
hs = h.iloc[-20:]
p = h.iloc[-1]
What is Difference Between 3 Variables Shown?
hs1 = history.iloc[:20]
hs2 = history.iloc[20:]
hs3 = history.iloc[-20]
history
creates a data sets of 4 asset prices, as can be seen from image under "additional info"
Ive researched and learned data iloc
is a pandas indexing and referencing function
However what I do not understand is the [:20]
, [20:]
, [-20]
indexes(?) attached to iloc
function in the 3 example variables shown above
Questions
hs1 = history.iloc[:20]
, According to my research following python programming tutorial on pandas dataframehs1 = history.iloc[:20]
singles out deletes the first 20 columns within the dataframe, is this correct?hs2 = history.iloc[:20]
What is difference to above variable?hs3 = history.iloc[-20]
Why a minus-
and no:
inside the index?
Additional Info
History variable creates dataset of 3 assets
Hope this makes sense, please comment if you need any additional info any help and advice much appreciated.