首页 > 解决方案 > 了解熊猫称呼

问题描述

我在我的代码上运行了 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)

标签: python-3.xpandascall-graph

解决方案


推荐阅读