01-21-2022 06:48 AM
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
prob = np.random.rand(7) + 0.1
prob /= prob.sum()
df = pd.DataFrame({'department': np.random.choice(['helium', 'neon', 'argon', 'krypton', 'xenon', 'radon', 'oganesson'],
1000, p=prob),
'left': np.random.choice(['yes', 'no'], 1000)})
with this code, I can see the value labels in my Anaconda's Jupyter however, they are not displayed in my Databricks notebook? any idea how to fix?
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
prob = np.random.rand(7) + 0.1
prob /= prob.sum()
df = pd.DataFrame({'department': np.random.choice(['helium', 'neon', 'argon', 'krypton', 'xenon', 'radon', 'oganesson'],
1000, p=prob),
'left': np.random.choice(['yes', 'no'], 1000)})
sns.set_style('white')
filter = df['left'] == 'yes'
g = sns.catplot(data=df[filter], kind='count', y='department', palette='mako_r',
order=df[filter]['department'].value_counts(ascending=True).index)
for ax in g.axes.flat:
ax.bar_label(ax.containers[0], fontsize=12)
ax.margins(x=0.1)
plt.tight_layout()
plt.show()
the bar_label attributes are used in matplotlib.pyplot version 3.4.2.
I am using ML runtime 7.3. how can I upgrade?
thank you.
01-22-2022 11:41 AM
01-21-2022 12:38 PM
Hello again! Thanks for asking. We'll wait for the community to respond before we circle back around.
We appreciate your patience. 🙂
01-21-2022 04:39 PM
You need to use the display function for plotting visualizations.
Here are the docs:
https://docs.databricks.com/notebooks/visualizations/charts-and-graphs-python.html
https://docs.databricks.com/notebooks/visualizations/charts-and-graphs-python.html
To upgrade your runtime, just choose a different rundown from the cluster creation dropdown window.
01-22-2022 11:41 AM
01-26-2022 08:53 AM
@Maria Bruevich - Do either of these answers help? If yes, would you be happy to mark one as best so that other members can find the solution more quickly?
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group