After running

import numpy as np 
randn = np.random.randn
from pandas import *

the following code creates a panel:

## Create pseudo panel data ##
numindivs = 2 # Number of individuals
numwaves = 5 # Number of time periods (waves)

# Create panel object
wp = Panel(np.random.randint(12, size=(numindivs, numwaves, 4)), minor_axis=['background', 'lnH', 'F', 'T'])

# Generate random fixed background variable for each indiv: N(2,1)
wp.ix[:,:,'background'] = np.tile(randn(numindivs)+2,(numwaves,1))

# Generate lnF and lnT
wp.ix[:,:,'lnF'] = np.log(wp[:,:,'F']+1)
wp.ix[:,:,'lnT'] = np.log(wp[:,:,'T']+1)

Yet, the following code, which is identical except for changing the contents of the 'background' column in the penultimate section, generates an error ("ValueError: could not broadcast input array from shape (2) into shape (5)"):

## Create pseudo panel data ##
numindivs = 2 # Number of individuals
numwaves = 5 # Number of time periods (waves)

# Create panel object
wp = Panel(np.random.randint(12, size=(numindivs, numwaves, 4)), minor_axis=['background', 'lnH', 'F', 'T'])

# Generate lnF and lnT
wp.ix[:,:,'lnF'] = np.log(wp[:,:,'F']+1)
wp.ix[:,:,'lnT'] = np.log(wp[:,:,'T']+1)

This is extremely odd behavior. I am new to pandas; a contributor on StackOverflow suggested it "probably has something to do with how dtypes are getting coerced when you assign", hence the title of the issue. Thanks!

Comment From: jreback

closing as Panels are deprecated