for each period specified
by stick input
transdat = dat.loc[:,["Open", "High", "Low", "Close"]] if (type(stick) == str): if stick == "day": plotdat = transdat stick = 1 # Used for plotting elif stick in ["week", "month", "year"]: if stick == "week": transdat["week"] = pd.to_datetime(transdat.index).map(lambda x: x.isocalendar()[1]) # Identify weeks elif stick == "month": transdat["month"] = pd.to_datetime(transdat.index).map(lambda x: x.month) # Identify months transdat["year"] = pd.to_datetime(transdat.index).map(lambda x: x.isocalendar()[0]) # Identify years grouped = transdat.groupby(list(set(["year",stick]))) # Group by year and other appropriate variable plotdat = pd.DataFrame({"Open": [], "High": [], "Low": [], "Close": []}) # Create empty data frame containing what will be plotted for name, group in grouped: plotdat = plotdat.append(pd.DataFrame({"Open": group.iloc[0,0], "High": max(group.High),
推荐阅读
WOT讲师杨钊:人工智能将在不同应用场景逐步落地
【51CTO.com原创稿件】由51CTO主办的WOTA2017全球立异技巧峰会将于2017年7月21日拉开帷幕。本次峰会,将环绕机>>>详细阅读
本文标题:用Python做股市数据分析(一)
地址:http://www.17bianji.com/lsqh/36070.html
1/2 1