Difference-in-difference in panel data Under which conditions should we expect the difference-in-difference estimate to be equal to the equivalent panel data model? 
Strictly speaking, whenever we have a experiment that offers a well defined treated and control groups in two periods of time, for using difference-in-difference methods, people recommend running OLS of models such as:
Stata:

reg y post treatment postXtreatment

and the coefficient on "postXtreatment" would represent the treatment effect 

At the same time, in case we have panel data for two periods we can run:

xi: xtreg y i.year postXtreatment, fe 

When exactly should we expect equivalence? Does it have anything to do with the panel being balanced? 
Just one more question, in case we have more years available is the fixed effect model in the fashion the described above a good way to infer the treatment effect?
 A: You would expect equivalence when T = 2. If you have more than 2 years, use the latter approach (the one that relies on fixed effects). Please see http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf for more. Note: xi: is redundant in the newer versions of Stata. 
A: As long as the treatment occurs at the same time for all units, the estimator of DiD is equivalent to the one from panel data (usually called Two-way fixed effects), as shown by Jeffrey Wooldridge in this paper, section 5. To show it, we can generate some random data, apply an effect and estimate with both methods.
np.random.seed(1)
n=10 #number of units
ID=np.arange(n) #list of IDs
t= 10 #periods of time 

#Create dataset
data=pd.DataFrame({'ID':np.tile(ID,t),'year':np.repeat(np.arange(t),n),
                   'after_treatment':(np.repeat([0,1],n*t/2)),'treatment':np.zeros(n*t)})
data.loc[data['ID']<3, 'treatment']=1 #Mark these units as treated in the dataset
data['interaction']=data['after_treatment']*data['treatment'] #Create interaction variable
ui= np.random.normal (0,2,n*t) #Error term centered in zero with constant variance
data['out']=2*data['after_treatment']+2*data['treatment']+3*data['interaction']+ui #generate outcome

First, let's estimate with the classic diff-in-diff equation:
$$Y_{it} = \beta_0 + \beta_1 \textrm{Post}_t + \beta_2 \textrm{Treated}_i + \beta_3 \textrm{Treated}_i  \textrm{Post}_t + e_{it}$$
print(smf.ols('out~after_treatment*treatment', data=data).fit().params[3])

The result is 2.8685.
If we estimate as a panel data including time and unit-fixes effects, we are doing:
$$y_{it}=\alpha_{i}+ \gamma_{t} +\tau_{it}TreatedxPost +\epsilon_{it}$$
df_panel=data.set_index(['ID', 'year'])
Y=df_panel["out"] #Dependent variable
X=df_panel[[ "interaction"]] #Independent variables
X=sm.add_constant(X) #adding constant
model=PanelOLS(Y,X, entity_effects=True, time_effects=True).fit()
print(model.params[1])

The result is the same, 2.8685
