Title: Panel constructor not properly called
Tags: python-3.x;panel;zipline
Question: I have code as following:
import pandas as pd
import numpy as np
import datetime
from datetime import datetime
from datetime import timedelta
import pytz
start_date = '2015-01-01'
end_date = '2017-09-15'
def data_symbol():
dates=pd.date_range(start_date,end_date)
df=pd.DataFrame(index=dates)
df_temp=pd.read_csv('/home/furqan/Desktop/python_data/AVN.csv',usecols=['Date','Open', 'High', 'Low', 'Close', 'Volume'],
parse_dates=True,index_col='Date',na_values=['nan'])
#df_temp = df_temp.rename(columns={'Close': 'price'})
df=df.join(df_temp)
df=df.fillna(method='ffill')
df=df.fillna(method='bfill')
df.index.names = ['Date']
return df
data = data_symbol()
print(data)
panel = pd.Panel(data)
panel.minor_axis = ['Open', 'High', 'Low', 'Close', 'Volume']
panel.major_axis = panel.major_axis.tz_localize(pytz.utc)
After printing data it results in an error as follows:
"Panel constructor not properly called!"
The data is as follows:
Open   High    Low  Close     Volume
Date
(526)248-8544.85  35.30  33.40  35.07  1222500.0
(526)248-8544.07  36.82  35.00  36.32  1252000.0
(526)248-8544.07  36.82  35.00  36.32  1252000.0
(526)248-8544.07  36.82  35.00  36.32  1252000.0
(526)248-8544.32  36.30  35.31  35.76   629500.0
(526)248-8544.76  35.92  34.75  34.87   585000.0
(526)248-8544.87  35.85  34.90  35.23   341000.0
(526)248-8544.23  35.50  34.76  34.92   253500.0
(526)248-8544.92  35.50  34.60  34.73   (526)248-8544
The purpose to convert it into panel data so that I can use the local data file in Zipline.
Comment: Not only is Panel halfway undocumented, it is now officially deprecated.  https://pandas.pydata.org/pandas-docs/stable/dsintro.html#dsintro-deprecate-panel  - you may want to reconsider using williamsscott@example.org.


Here is another answer: I just faced this problem recently and fixed it by changing this line:
data = data_symbol()
data['abc'] = data_symbol()
change 'abc' into whatever name you like

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:09/16/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python-3.x><panel><zipline>', 'Title': 'Panel constructor not properly called', 'ViewCount': 491, 'id': 46258700, 'user_AboutMe': '', 'user_AccountId': 9895236.0, 'user_DisplayName': 'Furqan Hashim', 'user_Reputation': 1252.0, 'user_Views': 381.0, 'user_id': 7326981.0}}