You can use the pandas cut function to bin the data into specific intervals.
Use this code, and edit as per your data (replace 'column_name' with the actual column name in the data):
cut_bins = [59200, 59400, 59600, 59800, 60000, 60200, 60400, 60600, 60800]
pd.cut(df['column_name'], bins=cut_bins)
You can also use np.linspace to create a list of bins like this:
cut_bins = np.linspace(59200, 60800, 9)
If you want to bin a value into 8 bins and just count the number of occurrences in each, use this code:
df['column_name'].value_counts(bins=8, sort=False)
To learn more about pandas cut and qcut functions, please visit this link.
Comments
0 comments
Article is closed for comments.