Imputing values with non-negative matrix factorization
In the while loop, the first call you make to nmf_model.fit_transform() is superfluous and can be removed.  You aren't even using the results of the transformation calculation.  The next line, where you have W = nmf_model.fit_transform(X_imputed.values) is doing all the work.  Removing this line halves the number of model fits and speeds things up by ~twofold.
You don't need to assign H outside/before the while loop.
If minimization of code lines is the goal, you can avoid assigning to temporary variables and just put the expression that you would have used to define the variable in the code line that uses it.  I did that for H in the while loop.  It is more compact but probably harder to understand.
You don't seem to need to full pandas module, so that import can be removed.
I didn't change anything in my code below, but why are you squaring nmf_model.reconstruction_err_?  According to the docs this error is the Frobenius norm of the difference matrix (X - WH), so it will always be positive even without squaring.


This is a tad more compact and significantly faster (because of item 1):

from pandas import DataFrame
import numpy as np
from sklearn.decomposition import ProjectedGradientNMF

# Example data matrix X
nrows, ncols = 200, 150
toy_vals = np.random.random(nrows*ncols).reshape((nrows, ncols))
toy_vals[toy_vals &lt; 0.9] = np.nan
X = DataFrame(toy_vals, index=range(nrows), columns=range(ncols))

# Hiding values to test imputation
X_imputed = X.copy()
msk = (X.values + np.random.randn(*X.shape) - X.values) &lt; 0.8
X_imputed.values[~msk] = 0

# Initializing model
nmf_model = ProjectedGradientNMF(n_components=5)
nmf_model.fit(X_imputed.values)

# iterate model
while nmf_model.reconstruction_err_**2 &gt; 10:
    W = nmf_model.fit_transform(X_imputed.values)
    X_imputed.values[~msk] = W.dot(nmf_model.components_)[~msk]
    print nmf_model.reconstruction_err_