Forum Discussion
Titanic dataset with Python in Power BI for making visuals
Hi all,
I try to import titanic dataset in Power BI, and make some basic Python visualisations.
In the query editor I can succelfully import the dataset using this Python code:
import pandas as pd
url = "http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic3.xls"
titanic_df = pd.read_excel(url)
Then I load the data to the Power BI report, so I choose for a Phython visual type.
I want some basic visualisations using the Survived column, so I add column Survived in the values pane of the Phython visual type. Now I enter this code:
even with changing data=titanic_df to data=dataset I don't get a result.
I Jupyter notebooks this works fine. Python and the 3 packages (np,pd,sns) are installed on my machine and seem to work for other very small datasets (like a self constructed small dataframe of shape 2*2).
Anyone who knows how to do this?
Thanks in advance!
Hi FilipFireFlyBI ,
Try this:
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set_style('whitegrid') ax = sns.countplot(x='survived',data=dataset) plt.show()Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- Icey
Community Support
Hi FilipFireFlyBI ,
Try this:
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set_style('whitegrid') ax = sns.countplot(x='survived',data=dataset) plt.show()Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.