return [data for data in cursor]
//for item in cursor:
__data = pd.DataFrame([item for item in cursor])
__data = __data.assign(date=pd.to_datetime(__data["date"]))
// __data.append([str(item["code"]), float(item["open"]), float(item["high"]), float(
// item["low"]), float(item["close"]), int(item["up_count"]), int(item["down_count"]), float(item["vol"]), float(item["amount"]), item["date"]])
// 多种数据格式
if format in ["n", "N", "numpy"]:
__data = numpy.asarray(__data)
elif format in ["list", "l", "L"]:
__data = __data
elif format in ["P", "p", "pandas", "pd"]:
// __data = DataFrame(
// __data, columns=["code", "open", "high", "low", "close", "up_count", "down_count", "volume", "amount", "date"])
// __data["date"] = pd.to_datetime(__data["date"])
__data = __data.set_index("date", drop=False)
else:
print("QA Error QA_fetch_index_day format parameter %s is none of \"P, p, pandas, pd , n, N, numpy !\" " % format)
return __data
else:
QA_util_log_info("QA something wrong with date")
After Change
res = pd.DataFrame([item for item in cursor])
try:
res = res.assign(volume=res.vol, date=pd.to_datetime(
res.date)).drop_duplicates((["date", "code"])).query("volume>1").set_index("date", drop=False)
except:
res = None
if format in ["P", "p", "pandas", "pd"]:
return res
elif format in ["json", "dict"]:
return QA_util_to_json_from_pandas(res)
// 多种数据格式
elif format in ["n", "N", "numpy"]:
return numpy.asarray(res)
elif format in ["list", "l", "L"]: