xxyao
xxyao

Reputation: 549

Shape of passed values is (3514, 78), indices imply (1, 78)

I want to construct a Dataframe through:

alpha = pd.DataFrame(np.zeros_like(close),index=close.index,columns['close'])

and part of close are presented below

stcode    000001.SZ  000002.SZ  000004.SZ  000005.SZ  000006.SZ  000007.SZ
trade_dt                                                                     
20180102  1456.4304  4470.4898    90.7867    40.0360   327.2121   138.0036   
20180103  1417.0962  4438.9108    96.7199    39.5727   327.2121   138.0036   
20180104  1408.5915  4547.3778    94.4442    39.7580   327.2121   138.0036   
20180105  1413.9069  4772.5499    94.2003    40.2214   327.2121   138.0036   
20180108  1377.7619  4941.4290    92.8186    40.4994   327.2121   138.0036 

and part of the close.index are presented below:

 Int64Index([20180102, 20180103, 20180104, 20180105, 20180108],
            dtype='int64', name='trade_dt')

I suppose that maybe the np.zeros_like(close) is multiIndex but close.index is single index. But I don't know how to fix it.

Upvotes: 1

Views: 100

Answers (1)

jezrael
jezrael

Reputation: 862406

I think need:

alpha = pd.DataFrame(0, index=close.index,columns=['close'])
print (alpha)
          close
20180102      0
20180103      0
20180104      0
20180105      0
20180108      0

Upvotes: 1

Related Questions