python-3.x - 了解熊猫称呼
问题描述
我在我的代码上运行了 PyCharm 分析器并转到以下调用图。
new_method(左起第二个)被调用,但是我的代码中没有任何名为 new_method 的函数。我假设它来自我在下面的代码中分配 close_price 的位置。如果是这样,是否有更好的方法从不需要这么长时间的数据框中分割数据?
def base_algo(conn):
#start_date = datetime.strptime("2000-09-22", "%Y-%m-%d")
start_date = datetime.strptime("2020-07-02", "%Y-%m-%d")
end_date = datetime.strptime("2020-07-23", "%Y-%m-%d")
current_date = start_date
while current_date < end_date:
historical_data = select_historical_data(conn, current_date)
buy_sell_signal = pd.DataFrame()
for stock in historical_data["stock"].unique():
close_price = historical_data[historical_data["stock"] == stock].close_val
slope_50 = calculate_slope(close_price, 50)
slope_200 = calculate_slope(close_price, 200)
to_append = {"stock":stock, "slope_50":slope_50, "slope_200":slope_200}
buy_sell_signal = buy_sell_signal.append(to_append, ignore_index=True)
current_date = current_date + timedelta(days=1)
解决方案
推荐阅读
- mysql - 如何在 MongoDB 中生成不在集合中的随机字符串?
- laravel - Laravel Seeding 产生的结果是预期的 3 倍
- python - ImageTk 模块有问题
- c# - 使用 gtk# 将文件从程序和拖放文件拖到任何地方(例如桌面等)
- angular - 延迟 Observable
- visual-studio - 在 Visual Studio 2019 中,通过测试的绿色和白色复选图标有什么区别?
- java - SpringBoot缓存,从@Cacheput方法调用@Cacheable方法不起作用
- php - 比较 2 个 csv 文件并在匹配时突出显示行
- reactjs - 如何处理 onChange ReactJs?里面的细节无法解释
- python - 时间序列预测:如何改进我的回归模型?