Skip to content

Instantly share code, notes, and snippets.

@BeatriceMoissinac
Created May 25, 2018 21:31
Show Gist options
  • Save BeatriceMoissinac/6fff9e2396bb3d8c7ab940a76ff7a186 to your computer and use it in GitHub Desktop.
Save BeatriceMoissinac/6fff9e2396bb3d8c7ab940a76ff7a186 to your computer and use it in GitHub Desktop.
[Bin data] How to put continuous data into bins #Python
import pandas as pd
df['bin'] = pd.cut(df['1'], [0, 50, 100,200], labels=['0-50', '50-100', '100-200'])
0 1 file bin
0 person1 24 age.csv 0-50
1 person2 17 age.csv 0-50
2 person3 98 age.csv 50-100
3 person4 6 age.csv 0-50
4 person2 166 Height.csv 100-200
5 person3 125 Height.csv 100-200
6 person5 172 Height.csv 100-200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment