histogram? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

histogram?

I have a data set of data with 7 different variables. how do you make the histogram of a variable?

2nd Feb 2018, 5:47 PM
eri
3 Answers
+ 5
I really recommend matplotlib module for that. However, if you don't have one: https://code.sololearn.com/cV6FMS7VmVPl/?ref=app (below find a code I made once for a similar inquiry ;)
2nd Feb 2018, 8:07 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
Try this: import matplotlib.pyplit as plt import pandas as pd data = pd.read_csv(your_filename_here, dtype=your_datatypes_here) # here you have read the data as proper datatypes, so that the data is of any numeric format # draw the histogram plt.figure(figsize=(10, 8)) plt.hist(data) plt.show() If you have any problems, please save your code here and publish it, so we can see and may help you.
3rd Feb 2018, 6:09 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
Oh, I see it's a Python2 syntax, not Python3. Make sure your implementation is a proper one. When using read_csv, add a parameter dtype={'profit': np.float32, 'invest': np.float32} Perhaps it is read as strings and that's why histplot doesn't work. Also, for a dataset summary, you might want to try the .describe() method. It's very informative and it's just one line to add :) print(df.describe())
3rd Feb 2018, 12:05 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar