Issue
The data is a column extracted from another dataframe.
Result
0 29
1 1
2 1
3 22
4 370
... ...
916 42
917 1
918 2200
919 200
920 770
Here is the graph with code df.hist()
Basically I want to find the boundary values on the x-axis
of the first bin so as to separate it from the rest of the bins. How can I do this?
Solution
x = df["columnName"] # your data, a column from a pandas dataframe
no_of_bins = 10 # the default value for the hist function
min_value = min(x)
max_value = max(x)
bin_size = (max_value - min_value)/no_of_bins
print("Bin size", bin_size)
print("Min value", min_value)
print("Max value", max_value)
# Show the bin boundary values
# initiate values
lower_boundary = min_value
upper_boundary = min_value + bin_size
for i in range(no_of_bins):
print("[", lower_boundary, "-", upper_boundary, "]")
lower_boundary = upper_boundary
upper_boundary = upper_boundary + bin_size
Answered By - ZaraA
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.