Home>

transform_data = transform_vector (stock_total) and an error occurred.

  • Answer # 1

    It was faster to recreate from the data

  • Answer # 2

    I wonder what this is like

    user_dct = {100: "Tom", 101: "Jon", 102: "Daisy"}
    dfs = []
    for key, value in user_dct.items ():
        file = './'+value+'.csv'
        dfs.append (pd.read_csv (file, parse_dates = ['Date']))
    df = pd.concat (dfs, ignore_index = True)
    idx = pd.date_range ('2011-01-01', '2011-12-31')
    multi_idx = pd.MultiIndex.from_product ([idx, df ['ID']. unique ()], names = ['Date', 'ID'])
    df = pd.DataFrame (index = multi_idx) .join (df.set_index (['Date', 'ID']))
    df = df.reset_index (). pivot (index = 'Date', columns = 'ID')
    print (df)