0
df = pd.read_csv("C:/Users/16316/Desktop/PsychologyData/1.csv")
df_Male = df[df['Subgroup'] == 'Male']
df_Male
df_Male.index
df_Male.set_index("Week Label")

Indicator   Group   State   Subgroup    Week    Value   Low CI  High CI Confidence Interval Quartile range
Week Label                                      
Apr 23 - May 5  Symptoms of Depressive Disorder By Gender   United States   Male    1   20.8    19.6    22.0    19.6 - 22.0 NaN
Apr 23 - May 5  Symptoms of Anxiety Disorder    By Gender   United States   Male    1   26.1    24.7    27.5    24.7 - 27.5 NaN
Apr 23 - May 5  Symptoms of Anxiety Disorder or Depressive Dis...   By Gender   United States   Male    1   31.0    29.6    32.3    29.6 - 32.3 NaN
May 7 - May 12  Symptoms of Depressive Disorder By Gender   United States   Male    2   22.3    20.6    24.0    20.6 - 24.0 NaN
May 7 - May 12  Symptoms of Anxiety Disorder    By Gender   United States   Male    2   26.7    24.9    28.5    24.9 - 28.5 NaN
May 7 - May 12  Symptoms of Anxiety Disorder or Depressive Dis...   By Gender   United States   Male    2   31.4    29.5    33.3    29.5 - 33.3 NaN
May 14 - May 19 Symptoms of Depressive Disorder By Gender   United States   Male    3   22.1    21.0    23.3    21.0 - 23.3 NaN

How do I separate this data so it only shows data sorted by 'Male' and 'Symptoms of Depression disorder'. I only want to the rows with Male of Sympts. of Depression disorder to appear

I'm not sure if it's displayed correctly but the columns that I want are Subgroup Male, and Indicator Symptoms of depressive disorder

There's also 1000's of rows in the rest of the data

Nicole
  • 9
  • 1
  • 3
  • Hi, can you please show a better version of what data you get and what data you'd like to get? – a_jelly_fish Jun 30 '20 at 13:48
  • https://imgur.com/a/uQ59bRf this is a picture of the data it says it wouldn't let me upload a picture since i'm new I want to remove all the rows but symptoms of depression disorder. I've separated by Gender but i'm not sure how to continue and separate more. any help is appreciated thank you. I'm pretty new to pandas and python – Nicole Jun 30 '20 at 13:59
  • df_depdisorder = df[df.Indicator== 'Symptoms of Depressive Disorder'] - just the way you've separated the 'Male' records into df_Male. Unless I haven't understood your question correctly. – a_jelly_fish Jun 30 '20 at 14:12
  • Sorry let me show another picture to make it more clear. There's also other subgroups that's not only male but sorted by other things. I want to have it so it's only male and depressive disorder together. I want to get rid of the other subgroups and indicators https://imgur.com/a/INd2tRo – Nicole Jun 30 '20 at 14:25
  • Looks like you could just add multiple conditions with an 'and' - df = df[(df.Subgroup=='Male') & (df.Indicator=='Symptoms of Depressive Disorder')] – a_jelly_fish Jun 30 '20 at 14:40
  • Also, for the future you can use the image icon seen while editing the question to paste links to pictures or upload from your computer. – a_jelly_fish Jun 30 '20 at 14:42

1 Answers1

0
df = df[(df.Subgroup=='Male') & (df.Indicator=='Symptoms of Depressive Disorder')] 

The '&' can help club multiple conditions to filter the data. For future reference, you could look at the various examples given here.

a_jelly_fish
  • 478
  • 6
  • 21