The names of many variables are too long. I want to have more space for the names. Thank you!
Here is the code:
`
nullIndex = df_loan_2018q1.isnull().any().index[df_loan_2018q1.isnull().any()]
nullTrain = df_loan_2018q1.loc[:, nullIndex].copy()
for col in nullTrain.columns:
nullPos = nullTrain[col].isnull()
nullTrain.loc[~nullPos, col] = ‘Exist’
nullTrain.loc[nullPos, col] = ‘Null’
nullTrain = nullTrain.apply(lambda x: pd.Series.value_counts(x)).T
nullTrain = nullTrain.sort_values(‘Exist’)
trace1 = go.Bar(
x = nullTrain[‘Exist’],
y = nullTrain.index,
name = ‘Exist’,
orientation = ‘h’,
marker = dict(
color = ‘rgba(246, 78, 139, 0.6)’,
line = dict(
color = ‘rgba(246, 78, 139, 1.0)’,
width = 3)
)
) # the pink one
trace2 = go.Bar(
x = nullTrain[‘Null’],
y = nullTrain.index,
name = ‘Null’,
orientation = ‘h’,
marker = dict(
color = ‘rgba(58, 71, 80, 0.6)’,
line = dict(
color = ‘rgba(58, 71, 80, 1.0)’,
width = 3)
)
) # represent the null values: gray
Picture of Null
data = [trace1, trace2]
layout1 = go.Layout(
width=800, height=1600, barmode=‘stack’, title=‘Null Value BarPlot’)
fig = go.Figure(data=data, layout=layout1)
#print((df_train.isnull().sum()[df_train.isnull().sum() != 0]) / df_train.shape[0])
#print(’’)
py.iplot(fig)`