-
Notifications
You must be signed in to change notification settings - Fork 3
/
meetupSpeakerWide.py
32 lines (23 loc) · 1.58 KB
/
meetupSpeakerWide.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
import numpy as np
#read in annotated tech meetup descriptions with speaker info
meetup = pd.read_csv('techMeetupsNotatedDone.csv')
#filter to necessary columns (nonBinary was removed because it's zero throughout and will be noted in graphs) and only applicable meetups (i.e., not hacknights, etc.)
meetup=meetup[meetup['applicable'] == 1]
meetup=meetup.drop(['applicable','desc','name','time','nonBinary'],axis=1)
# #shorten names for viz
meetup['g']=meetup['group']
meetup['g']=meetup['group'].str.replace('Austin Texas','ATX').str.replace('Austin ', '')
meetup['g']=meetup['g'].str.replace(' Group','').str.replace('Group Austin','').str.replace(' Circle','').str.replace('Web Design & Developer ','Design & Dev').str.replace('Meetup','').str.replace('The Austin','').str.replace('The ', '').str.replace('Programming', 'Prog')
# meetup['g']=meetup['g'].replace('[^a-zA-Z\d\s]+','',regex=True)
#identify multi vs. single speaker events and sum gender for each meetup type and group
meetup['singleSpeaker'] = np.where(meetup['male'] + meetup['female'] == 1, 'yes', 'no')
meetupSum=meetup.groupby(['g','singleSpeaker']).sum().add_prefix('sum_')
meetupSum=meetupSum.rename(columns = {'sum_male':'Male','sum_female':'Female'})
meetupSingle= meetupSum.loc[(meetupSum.index.get_level_values('singleSpeaker') == 'yes')]
meetupSingle.index = meetupSingle.index.droplevel(1)
meetupMulti= meetupSum.loc[(meetupSum.index.get_level_values('singleSpeaker') == 'no')]
meetupMulti.index = meetupMulti.index.droplevel(1)
#output
meetupSingle.to_csv('SingleSpeaker.csv')
meetupMulti.to_csv('MultiSpeaker.csv')