File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 66 "metadata" : {},
77 "outputs" : [],
88 "source" : [
9+ " from compiler_admin.services.google import user_info as google_user_info\n " ,
910 " import json\n " ,
1011 " import os\n " ,
1112 " from pathlib import Path\n " ,
127128 " source[\" First Name\" ] = source[\" First Name\" ].astype(\" category\" )\n " ,
128129 " source.dtypes"
129130 ]
131+ },
132+ {
133+ "cell_type" : " code" ,
134+ "execution_count" : null ,
135+ "metadata" : {},
136+ "outputs" : [],
137+ "source" : [
138+ " # Get cached last name or query from Google\n " ,
139+ " def get_last_name(email: str):\n " ,
140+ " user = USER_INFO.get(email)\n " ,
141+ " last_name = user.get(\" Last Name\" ) if user else None\n " ,
142+ " if last_name is None:\n " ,
143+ " user = google_user_info(email)\n " ,
144+ " last_name = user.get(\" Last Name\" ) if user else None\n " ,
145+ " if email in USER_INFO:\n " ,
146+ " USER_INFO[email].update(user)\n " ,
147+ " else:\n " ,
148+ " USER_INFO[email] = user\n " ,
149+ " return last_name\n " ,
150+ " \n " ,
151+ " source[\" Last Name\" ] = source[\" Email\" ].apply(get_last_name)\n " ,
152+ " source[\" Last Name\" ] = source[\" Last Name\" ].astype(\" category\" )\n " ,
153+ " source.dtypes"
154+ ]
130155 }
131156 ],
132157 "metadata" : {
You can’t perform that action at this time.
0 commit comments