From 6e5ebe6c161ff09f25d8dae87d806a3979283cf9 Mon Sep 17 00:00:00 2001 From: John-Paul Robinson <jpr@uab.edu> Date: Thu, 25 Aug 2022 14:03:01 -0500 Subject: [PATCH] Add uid to username resolution for dataframe Add column and update logic to add username values from the the system password database. --- scratch-log-explorations.ipynb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scratch-log-explorations.ipynb b/scratch-log-explorations.ipynb index 999e9a9..e360063 100644 --- a/scratch-log-explorations.ipynb +++ b/scratch-log-explorations.ipynb @@ -329,8 +329,30 @@ "metadata": {}, "outputs": [], "source": [ + "# add new column for resolved uids\n", + "df[\"uname\"]=\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# set uname for uid\n", "for uid in sorted(df[\"uid\"].unique()):\n", - " print(\"uid: {} name: {}\".format(uid, pwd.getpwuid(int(uid))[0].split(\":\")[0]))" + " uname = pwd.getpwuid(int(uid))[0].split(\":\")[0]\n", + " print(\"uid: {} name: {}\".format(uid, uname))\n", + " df.loc[df[\"uid\"]==uid, [\"uname\"]] = uname" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df[df[\"uid\"]==10005]" ] }, { -- GitLab