Quantcast
Channel: Mockaroo Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 2665

Creating datasets with dependent columns

$
0
0

What you are looking for is binning. Since you have not provided the tech stack you are working on, I'll provide an example with pandas DataFrame.

For age, you would have to define the bins=[10,25,50,90] and groups = [a,b,c]
Now, to create a new column in the DataFrame with this binned values:

df['new_categories'] = pd.cut(df['Age'],bins=bins, labels=groups])

This basically groups the age in the bins that you have provided, say (10-25] and marks it as 'a' in a new column called 'new_categories'.

Hope this helps.


Viewing all articles
Browse latest Browse all 2665

Trending Articles