Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

abstracting 2 columns from a dataset with a specific sample of 10

this is a sample diabetics dataset

I want to get only the 2 mentioned columns as the output but i am not sure about the code for that

df.get("gender", "heart_disease")

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried this and the code is working but I am only getting the output of gender want only 10 sample outputs. how do i get that?

>Solution :

First, subset the pandas data frame using the df[list of columns] notation then sample

df[['gender', 'heart_disease']].sample(10)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading