Python : adding a columns with count of missing values by row
The difference between the two code snippets is that the first creates a new DataFrame while the second modifies the original DataFrame in-place.
The first snippet can be simplified to
X_ = dfObj.assign(nan_count=dfObj.isna().mean(axis=1).astype('float32'))