import plotly.express as px
tips = px.data.tips()
tips
px.histogram(tips, x="total_bill", y="tip", histfunc="sum", color="smoker")
just a few lines and there are already all this data in "tips", I am very confused where do those number coming from? Thanks a lot tips
Out[125]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
.. ... ... ... ... ... ... ...
239 29.03 5.92 Male No Sat Dinner 3
240 27.18 2.00 Female Yes Sat Dinner 2
241 22.67 2.00 Male Yes Sat Dinner 2
242 17.82 1.75 Male No Sat Dinner 2
243 18.78 3.00 Female No Thur Dinner 2
[244 rows x 7 columns]
Using
import plotly.express as px
print(px.data.__file__)
you can see path to source code and check it.
Digging in source code I found that on Linux data are in folder
/usr/local/lib/python3.7/dist-packages/plotly/package_data/datasets/
as .csv files compressed to .gz files so pandas.read_csv() can read it without problem.
And tips() uses pandas.read_csv() to read it.
You can display other functions in px.data which reads datasets using dir()
import plotly.express as px
for name in dir(px.data):
if '__' not in name:
print(name)
Result
absolute_import
carshare
election
gapminder
iris
tips
wind
Probably all of them (except absolute_import) are functions which reads some .gz file with data.
print(px.data.carshare())
print(px.data.election())
print(px.data.gapminder())
print(px.data.iris())
print(px.data.tips())
print(px.data.wind())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With