<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yusuf Sohoye on Medium]]></title>
        <description><![CDATA[Stories by Yusuf Sohoye on Medium]]></description>
        <link>https://medium.com/@yusufsohoye?source=rss-9d60a2844fe8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nIQSxqYoFiqQeigLrgBgjw.png</url>
            <title>Stories by Yusuf Sohoye on Medium</title>
            <link>https://medium.com/@yusufsohoye?source=rss-9d60a2844fe8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:58:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yusufsohoye/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Impact of COVID-19 on the UK BAME population]]></title>
            <link>https://medium.com/data-science/impact-of-covid-19-on-the-uk-bame-population-cc09244c5d63?source=rss-9d60a2844fe8------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc09244c5d63</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[bame]]></category>
            <category><![CDATA[open-data]]></category>
            <dc:creator><![CDATA[Yusuf Sohoye]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 13:42:06 GMT</pubDate>
            <atom:updated>2020-07-29T13:42:06.643Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using open data to provide a descriptive view of the socio-economic factors affecting the UK BAME population during COVID-19</h4><blockquote><em>“…the virus knows no race or nationality; it can’t peek at your driver’s license or census form to check whether you are black. Society checks for it, and provides the discrimination on the virus’s behalf.</em>” — <a href="https://www.theatlantic.com/ideas/archive/2020/05/we-dont-know-whats-behind-covid-19-racial-disparity/612106/">Game Wood — The Atlantic</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1iZiiUzx3vLn5fvDY_hYw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@samuelryde?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Samuel Ryde</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>There is growing concern that coronavirus has had a <a href="https://www.bhf.org.uk/informationsupport/heart-matters-magazine/news/behind-the-headlines/coronavirus/coronavirus-and-bame-patients">greater impact on people from ethnic minorities</a>. Black, Asian and Minority Ethnic (BAME) communities account for 14% of the population but make up <a href="https://www.theguardian.com/world/2020/apr/07/bame-groups-hit-harder-covid-19-than-white-people-uk">a third</a> of critically ill coronavirus patients in hospitals is the headline statistic. The <a href="https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/892085/disparities_review.pdf">Public Health England report</a> finds that there is a disproportionate impact of Covid-19 on people from all non-white ethnic minorities.</p><p>This article compares <a href="https://github.com/VictimOfMaths/COVID_LA_Plots">excess death statistics</a> with openly available socio-economic data to present a descriptive picture of the situation in England and Wales. Descriptive analysis uses 2011 census data to determine the ethnic mix of local authorities; an approach similar to one <a href="https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/articles/coronavirusrelateddeathsbyethnicgroupenglandandwales/2march2020to10april2020">used by the ONS</a>. As a result, the unit of observation will be local authorities. A full breakdown of raw data, transformation and analysis can be found and reproduced on GitHub.</p><blockquote><strong><em>Note from the editors:</em></strong><em> </em><a href="http://towardsdatascience.com/"><em>Towards Data Science</em></a><em> is a Medium publication primarily based on the study of data science and machine learning. We are not health professionals or epidemiologists, and the opinions of this article should not be interpreted as professional advice. To learn more about the coronavirus pandemic, you can click </em><a href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019/situation-reports"><em>here</em></a><em>.</em></blockquote><h3>What’s going on?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3IR2NLuAHk9rhe35yJRRQ.png" /><figcaption>Local Authority Ethnicity share against Excess Deaths <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/Excess%20Deaths%20and%20Ethnicity.ipynb">source</a></figcaption></figure><p>The above plot shows deaths occurring within a Local Authority against the proportional representation of a particular ethnicity in that Local Authority. Lines sloping upwards from left to right indicate that local authorities with higher proportion of BAME population see more excess deaths. Whereas the downward sloping purple line indicates that less ethnically diverse Local Authorities see lower number of excess deaths. It is important to note that data does cluster close to 0, and regression lines <a href="https://twitter.com/ryxcommar/status/1280268687455457281?s=20">fitted to this kind of clumped data</a> is not evidence of a relationship by itself. This is not measuring the impact to the BAME community directly, but instead comparing geographic areas more negatively affected by the virus, and it’s corresponding ethnic make up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*qDM6xDf9Bi8cw-Lk1GdErQ.png" /></figure><h3>Age</h3><p>Before we look at the location specific factors affecting virus’ impact, we must consider the age of the afflicted, which we understand to be a contributing factor to the mortality of COVID-19. Data published by the ONS contains <a href="https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/countsandratiosofcoronavirusrelateddeathsbyethnicgroupenglandandwales">counts of coronavirus-related deaths by ethnic group in England and Wales</a> and show that 88% of Coronavirus-related deaths are people over 64.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYzZGOJszmkWIpHGjvwH7Q.png" /><figcaption>COVID Deaths and Total Population <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/Ethnicity%20And%20Age%20Breakdown.ipynb">source</a></figcaption></figure><p>The figure above shows ethnic breakdown of all recorded covid deaths. Interestingly, this breakdown is fairly similar to the 2011 census statistics which showed a 14% of the population were BAME and the covid data shows that 16.2% of COVID deaths are BAME. There doesn’t seem to be a disproportionate effect on the BAME population.</p><p>To square this circle we can use a Dana Mackenzie blog post looking at <a href="http://causality.cs.ucla.edu/blog/index.php/2020/07/06/race-covid-mortality-and-simpsons-paradox-by-dana-mackenzie/">race and covid in the USA</a> through the Simpsons paradox. Presenting the below causal model, he assumes that ethnicity will influence chances of living to age 65 or older.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*tOazXiq6qsJRu5nUfEDRLQ.png" /></figure><p>This forms a chain, through which the causal effect can pass through. If we are to ask, what is the effect of ethnicity <strong>only </strong>on Covid mortality, then we must hold all other variables constant. It follows that we should control for age and split by age, creating two groups ‘0–64’ and ‘65+’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtvdyDidIzKQfkaSfSo6fA.png" /><figcaption>Covid Deaths by Ethnicity for different Age Groups <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/Ethnicity%20And%20Age%20Breakdown.ipynb">source</a></figcaption></figure><p>Now we split COVID deaths by age; this shows a similar distribution, for the 65+ category. COVID deaths split by ethnicity roughly match the 2011 census ethnicity breakdown of the UK; 86% of the UK population are white and 85.7% of Covid deaths aged 65+ are also white. However, for the under 65 age bracket, there is a higher share of BAME deaths when compared to the UK population; 30.7% of covid deaths under 64 are from BAME communities, compared to 14% of the population.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yuQ3X-2sAZXFMoBmh_6i-w.png" /><figcaption>Population by Ethnicity for Different Age Groups <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/Ethnicity%20And%20Age%20Breakdown.ipynb">source</a></figcaption></figure><p>Finally, we split the population by ethnicity <strong>and </strong>age, now we can see a clear disparity between ethnicities for both age brackets. Now the BAME population under 65 make up of 30.7% covid deaths but only 14.3% of the population. 2011 census shows that the BAME population make up just 2.3% of the 65+ population, but account for 14.3% of the COVID deaths. This seems to indicate a very disproportionate impact on the BAME population. As shown, <a href="https://www.youtube.com/watch?v=ebEkn-BiW5k">grouping data differently</a> can lead to different results; assumptions about causal paths are essential when making these grouping decisions.</p><h3>Location: Living in Cities</h3><p>There may be some intrinsic/ biological condition that causes BAME people to be higher risk, but this is probably not the whole story. Poor living environments are well understood to contribute to health risks, recognised in multiple <a href="https://www.jstor.org/stable/j.ctt1729vxt">epidemiological studies</a>. Centric Lab <a href="https://www.thecentriclab.com/covid-19-poverty-a-london-data-study">released a report</a> taking an in-depth look at human health and urban environments. Economics Observatory also details the mechanisms through which <a href="https://www.coronavirusandtheeconomy.com/question/why-has-coronavirus-affected-cities-more-rural-areas">cities become coronavirus hotspots</a>, including occupational structures. These studies support the causal structure laid out below, where ethnicity will affect location decisions (immigrants settling in dense areas with increased employment opportunities), and these historic location patterns being passed down generations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3c3tAlRl0fcTcmnA0g7VxA.png" /></figure><p>To unpack “High Risk Urban Environments”, below is a correlation matrix of area specific attributes obtained using openly available data. Correlations calculated using Spearman’s and p-values shown <a href="https://github.com/Quotennial/covid_bame/blob/master/reports/figures/corr_pvals.csv">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CY4VYI64IB-DNHKeykQ_jQ.png" /><figcaption>Correlation Matrix (Spearman) <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/Excess%20Deaths%20and%20Ethnicity.ipynb">source</a></figcaption></figure><ul><li>Excess deaths are positively correlated with increased BAME populations, and negatively correlated with increased presence of white ethnic populations. The same pattern we saw in the first scatter plot.</li><li>Co-location of BAME population: Red cluster in the bottom right of the plot indicate co-location of BAME populations. In Local Authorities where there is a high proportion of any ethnic minority, there tends to be a higher proportion of other minorities as well.</li><li>Population density and BAME population: Population density is calculated using <a href="https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/populationestimatesforukenglandandwalesscotlandandnorthernireland">ONS population estimates</a> and size of local authority (then cross referenced with <a href="https://data.gov.uk/dataset/a76f46f9-c10b-4fe7-82f6-aa928471fcd1/land-area-and-population-density-ward-and-borough">GLA density estimates</a>). Showing that BAME ethnicities tend to live in more densely populated areas. When combined with government findings that ethnic minorities <a href="https://www.ethnicity-facts-figures.service.gov.uk/housing/housing-conditions/overcrowded-households/latest#by-ethnicity">live in cramped housing</a>; a picture of dense living for BAME populations emerges.</li><li>Excess deaths negatively correlated with higher number of people over 65, which also tend to be less densely populated and less ethnically diverse.</li><li>Portion Furloughed and the Index of Multiple Deprivation: Neither metrics show any real indication of a relationship.</li></ul><p>So far, we have only seen correlations that may give us a profile of the kind of high-risk local authorities. No fancy modelling or weighted metrics used so far, this follows from a <a href="https://www.tomforth.co.uk/coronavirusanddeprivation2/">piece Tom Forth wrote</a> about useful statistics and misleading metrics. He studies an adjacent concern — that most deprived areas are worse affected — but finds no evidence. I also find no strong relationship between deprivation and excess deaths. But Tom also highlights an important point about the social-justice element; BAME people are being affected but to uncover the real underlying factors — we must be unbiased in our analysis, not go trying to fit the data into our beliefs and hold our assumptions loosely.</p><p>Thus far data collection has been prioritised for monitoring, this can be an issue when trying to uncover causal links in “real time”; the 2011 census data is a year away from being officially outdated. Data being collected and published about Coronavirus is an ongoing, iterative process; collection methods and data quality can change weekly. For example; the <a href="https://www.inyourarea.co.uk/news/why-the-coronavirus-figures-you-see-on-inyourarea-increased-so-much/">omission of pillar II testing</a> shows us how drastically the “data” can shift. Chris Giles of the FT compares the new <a href="https://www.ft.com/content/366653da-fc7b-4f3d-bf2f-ef95dfc18041">speedy economic data to fast food</a> — tempting but bad for you. Reliance on data without understanding the causal structure can be misleading.</p><h3>Geospatial Analysis</h3><p>There has been no shortage of COVID map-dashboards; spatial analysis has been an <a href="https://www.wired.co.uk/article/uk-lockdown">important tool</a> in trying to contain and reduce the spread. The map below uses local Moran’s statistic which is: “the correlation coefficient for the relationship between a variable (like excess deaths) and its surrounding values” [<a href="https://mgimond.github.io/Spatial/spatial-autocorrelation.html#local-morans-i">ref</a>]. We use this measure to compare excess death rates of local authorities with neighbouring local authorities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8ElK4S3i7wG2r5DZf6diA.png" /><figcaption>Excess Deaths using Local Moran’s Statistic <a href="https://github.com/Quotennial/covid_bame/blob/master/notebooks/spatial_analysis.ipynb">source</a></figcaption></figure><p>The scatter plot on the left visualises the local authorities and relationship with their neighbours, coloured dots are statistically significant to p=0.05. The top right red quadrant shows that LA with high number of excess deaths are surrounded by other LA with similarly high excess deaths. Whereas the bottom left blue quadrant shows low excess deaths surrounded by other LA with low excess deaths.</p><p>On the map red areas indicate “covid hotspots”, we see a London cluster of local authorities and regions around Liverpool and Manchester highlighted as high number of excess deaths with similarly high neighbours. There is also a cluster near Leicester and Birmingham where a local lockdown was put in place.</p><h3>Conclusion</h3><p>The correlation matrix indicates the co-location of BAME population in dense areas and the spatial analysis shows the correlation of high excess deaths in urban areas — pointing towards the city’s role in increasing COVID alongside more BAME people living in cities. However, this reasoning ignores the inequality and polarisation within cities. Cities are where very different socio-economic groups live side by side. Analysis and policy solely focused on regions as a whole will miss these differences and more granular data would benefit this effort.</p><p>In uncertain times such as these, we often seek data to cling onto and provide some certainty; but more data about our world does not necessarily mean we understand more about our world. Complex models and machine learning won’t cleanse the data of errors and omitted testing numbers — but reinforce them. This has been a first run at trying to understand the impacts of COVID on BAME population in the UK.</p><p>In the meantime, the code and data (raw and clean) is all <a href="https://github.com/Quotennial/covid_bame">online</a>. I am aware the statistical methods used are quite simple and believe that this will help communicate the picture better than hiding meaning (and my mistakes!) behind complex modelling and caveats. Sometimes simplicity can provide more clarity than complex modelling approaches, and in these uncertain times, clarity is in short supply.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc09244c5d63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/impact-of-covid-19-on-the-uk-bame-population-cc09244c5d63">Impact of COVID-19 on the UK BAME population</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The One with all the FRIENDS Analysis]]></title>
            <link>https://medium.com/data-science/the-one-with-all-the-friends-analysis-59dafcec19c5?source=rss-9d60a2844fe8------2</link>
            <guid isPermaLink="false">https://medium.com/p/59dafcec19c5</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Yusuf Sohoye]]></dc:creator>
            <pubDate>Wed, 11 Sep 2019 16:42:18 GMT</pubDate>
            <atom:updated>2019-09-11T16:42:18.440Z</atom:updated>
            <content:encoded><![CDATA[<h3>The One with all the FRIENDS Data Analysis</h3><h4>Providing an alternative look at the most looked at show</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsRgfDFreOmWdTCM6YYH_Q.jpeg" /><figcaption>The crew (<a href="https://wall.alphacoders.com/tags.php?tid=38393&amp;lang=Portuguese">source</a>)</figcaption></figure><p>FRIENDS is one of my favourite shows (probably <em>the</em> favourite) and I’m sure I’m not alone in having rewatched the entire series more than once. I’ve always wondered if there was anything left to know about this oh-so familiar group. After seeing <a href="http://giorasimchoni.com/2017/06/04/2017-06-04-the-one-with-friends/">this post using R </a>to look at the show, I thought I would give it a go myself. This post dives into the show’s scripts to find out more, including the most popular characters and their journey through the seasons. But first it will introduce methods to format and export text files into a SQLite database using Python. The text files used in this projects contain scripts from the T.V. show F.R.I.E.N.D.S. and was downloaded from <a href="https://fangj.github.io/friends/">this repository</a>. Then provide some interesting findings about the characters we know so well, some expected and some surprising! It has been a really enjoyable hobby project and one I have been wanting to do for a while. Feel free to skip the coding bits and jump to the visualisations, hope you enjoy it!</p><h3>Iterating Through Scripts</h3><p>Each script is a text file containing some information about the episode, the title, writers and transcribers before the script actually starts. We need to find a way to turn a <strong>script</strong> into rows in a database and then work out how to do this for <strong>multiple scripts.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*LCd3I4j9sk_juWTotxaHVg.png" /><figcaption>Example of a Script in the .txt Files</figcaption></figure><p>We will start trying to iterate through the scripts. They are stored in multiple text files and helpfully titled using the format season.episode. We can utilise the OS library in python to navigate through our text files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*kYSExyJzUZzCxfcfhaRjIQ.png" /><figcaption>Currently where all Scripts are Stored</figcaption></figure><p>As it stands, the code below will iterate through all the files in our scripts folder to obtain the filename. This filename is then split using the . separator and those numbers are stored in variables to be appended to the master list. The master_list is created as eventually we will want to store the results in a DataFrame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be5f1ea8f4d8a5ca8214bef4e38a9770/href">https://medium.com/media/be5f1ea8f4d8a5ca8214bef4e38a9770/href</a></iframe><h3>Regular Expressions</h3><p>Now we know how to move through our FRIENDS files, we need to see how to isolate the lines from each file. To do so I will be using regular expressions, the scripts are quite messy and all formatted differently depending on the transcriber. The pertinent pattern is character_name: speech however this can sometimes span multiple lines. Regular Expressions is like a really powerful ctrl-F, they are used to search for patterns in strings, a nice intro on can be found <a href="https://medium.com/front-end-weekly/a-practical-beginners-guide-to-regex-regular-expressions-2faccbda117d">here</a>. The aim of our regular expression is to match the space before our intended line as indicated by the pink dots. We aim to find this space as we can then split the whole file using these positions, giving us groups of character-speech pairs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*5oE-wvL-CVQxaGXnKLZw1w.png" /><figcaption>Purple dots indicate where the expression will match</figcaption></figure><p>The regular expression used is shown below. First we mathc the string before a colon \w+(?=:), so now we have &quot;found&quot; the names of each character. However if we want to match the space before we must use \s. You can <a href="https://regex101.com/r/GFOGbq/2">test it out for yourself</a>, as you can see in the example, the regular expression also matches the space before the writers and transcribers, this will need to be removed after. Now we implement the regular expression in python. In the below code we are also able to split the character name and the speech.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8614a86ffaf4a8f749043768061570df/href">https://medium.com/media/8614a86ffaf4a8f749043768061570df/href</a></iframe><p>This is combined with our loop in the previous section and the mater_array is converted to a pandas data frame:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/151033d1bf5c7633da7e865d1bacf05c/href">https://medium.com/media/151033d1bf5c7633da7e865d1bacf05c/href</a></iframe><h3>Cleaning</h3><p>Despite our best efforts, the results are still not 100% ready for analysis. Our first issue is that there are multiple names for each character, this can be seen by executing sorted(df[&#39;char&#39;].unique()), this will return a list of all unique values in the column. To rectify this takes some manual work which involves looking at the multiple spellings of a certain name, case sensitive! To change the names we use the pandas replace method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf6369b9a3b265f06c440b0508fb1d90/href">https://medium.com/media/bf6369b9a3b265f06c440b0508fb1d90/href</a></iframe><p>Now we need to address the issues caused by our regular expression, as it caught the authors and transcribers. The format of these lines all end in <strong>by</strong>. Therefore the regular expression takes the last word before the colon as the character name. This means we can drop all of these rows by removing the character <strong>by</strong>. Bye by.</p><ul><li>Written<strong> by</strong></li><li>Transcribed <strong>by</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b203cd4d66f3f400cc2a953e01cff41/href">https://medium.com/media/4b203cd4d66f3f400cc2a953e01cff41/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*q63lyt3_GGuStWI7mErOeg.gif" /><figcaption>Clean data is key! via <a href="https://gfycat.com/gifs/search/monica+clean">gfycat</a></figcaption></figure><h3>Sentiment</h3><p>Sentiment analysis is on the table when dealing with strings, a more in-depth discussion can be found in <a href="https://quotennial.github.io/loveisland/">this blog post</a>. Similar methods are used, for each line in the database a sentiment score is calculated and stored in the line_sent column:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ec3d05454890ce6b9016693d9f33b91/href">https://medium.com/media/5ec3d05454890ce6b9016693d9f33b91/href</a></iframe><h3>Export to SQL</h3><p>Now this may not be a necessary step as most of the SQL commands we would be using could be done using pandas. However, I think sometimes altering different data frame scan sometimes get messy and SQL language may provide a ore readable way to access this data. Therefore we are now going to move the pandas dataframe into a SQL database. I am using <a href="https://sqlitebrowser.org/">DB Browser for SQLite</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3210812de60212d2b9e160e992ae9ed/href">https://medium.com/media/e3210812de60212d2b9e160e992ae9ed/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/827e519105edd60787aff8460c7f933e/href">https://medium.com/media/827e519105edd60787aff8460c7f933e/href</a></iframe><p>Finally our scripts are formatted and placed in a SQL database. Data wrangling in this way can transform raw data into a more useful data set. Even though we are not adding too much to the data set, the different organisational structure can enable a wider breadth of analysis. Now we have the scripts formatted in this way, we can utilise SQL to gain further insights into the show as carried out in <a href="https://quotennial.github.io/friends-analysis/">this article</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*tDhHzdoRT8-JSow46fn6gg.gif" /><figcaption>via <a href="https://tenor.com/search/brand-new-information-gifs">tenor</a></figcaption></figure><h3>The Most Popular Friend</h3><p>This section looks at each character’s role in the show. The previous post walked through the process of putting the data into a SQL database. This was in order to make a query like “who had the most number of lines during the whole series” fairly simple:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b299fcc407bc5b5de306f56e1b038cea/href">https://medium.com/media/b299fcc407bc5b5de306f56e1b038cea/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5rIS3VPmz6pYKxUp95Ixw.png" /></figure><p>Rachel just edges the top spot with 9294 lines over the entire series Ross coming in a very close second (9070), both averaging around 39-ish lines per episode. This isn’t entirely a shock, as they were both the main plot throughout 10 seasons. Almost inseparable are Monica and Chandler, 8403 and 8398 respectively.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a455f543767b16ff9165b1fd94f32d92/href">https://medium.com/media/a455f543767b16ff9165b1fd94f32d92/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gGbmKaLoVygArNh9VjAIUA.png" /></figure><p>A look at the number of lines breakdown throughout the series confirms this pattern, we can see Ross and Rachel dominating the lines until around Season 4. This is when the London episodes happen and Chandler and Monica have a bigger joint story, translating in more lines. I think it is a shame Phoebe never got more lines, staying rooted at around 800 lines per season. Rachel did say it:</p><blockquote>Ugh, it was just a matter of time before someone had to leave the group. I just always assumed Phoebe would be the one to go.<em> — Rachel 5.05</em></blockquote><h3>Most Spoken About</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*r8YeTey6K_XUG5w69nug8Q.gif" /><figcaption>via <a href="https://giphy.com/gifs/Friends-season-2-friends-tv-S9ndPlQlnSnqvGMMZv">giphy</a></figcaption></figure><p>Being the one doing the most talking does not necessarily mean you’re the most popular, so now we will take a look at who’s talked about the most. This is a pretty difficult task to accurately capture all mentions of each character. A possible solution is a list of nicknames for each character (let me know if I have missed any out!). It’s pertinent to note, this is the method we will use to find any reference to each character throughout this post, using the nicknames detailed below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59982f59c30dbc5ce8d67e91580ffc5f/href">https://medium.com/media/59982f59c30dbc5ce8d67e91580ffc5f/href</a></iframe><p>In order to get the count, we first iterate through the characters, keeping a count of the mentions. Using a nested for-loop to get each characters nickname, we use the pandas count() method to keep a tally of the number of mentions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71550667d14af1569bc59b1246519071/href">https://medium.com/media/71550667d14af1569bc59b1246519071/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PJCE7dJwedM7SMpqv7YRA.png" /></figure><p>When using only full names, Ross is the most mentioned. “Chan”, “Joe”, “Mon” and “Rach” are all mentioned more than their full names. This supports the decision to include the nicknames but does also highlight how sensitive the results are to picking the right names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgFxsuwZC6pSIbh0HnSHfw.png" /></figure><h3>Words</h3><h4>Catchphrases</h4><p>There are a few running catchphrases, for example “Smelly Cat “ was mentioned 37 times throughout the whole show. The infamous “We were on a break” line was referred to 17 times. And Joey’s pick up line “How you doin’” was said 37 times.</p><h4>Largest Vocabulary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*oaQ1l-gOP9tVmY5ZgR_WLA.gif" /><figcaption>via <a href="https://tenor.com/view/joey-friends-wisdomous-gif-7498897">tenor</a></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e322cdc1c397edd0911735ff27b525/href">https://medium.com/media/25e322cdc1c397edd0911735ff27b525/href</a></iframe><p>Another interesting aspect to look at is the lexicon of words each character uses. This is done by first selecting all the lines said by the main characters as shown above. After which all non alphabetical characters are removed. Every line by each characters is then split into words (using the space in between to split) and added to a set. A set allows no repeated values which is perfect for our use in this case.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdc52fb19a28018b8746179ea3b2818c/href">https://medium.com/media/bdc52fb19a28018b8746179ea3b2818c/href</a></iframe><p>Unsurprisingly Ross tops the list his passion for dinosaurs is a running joke throughout the series. Despite his career, starting off at the New York Museum of Prehistoric History and then professor at New York University, some real-life paleontologists <a href="https://redditblog.com/2015/10/24/an-actual-paleontologist-grades-friends-paleontologist-ross-gellar/">aren’t convinced</a>. I’m sure I’m not the only one surprised to see Joey in not-last-place. Given the role’s stereotypical caricature it appears Joey does have a couple of words up his sleeve, even if they are made up!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zl5xn_8dLKU157bPO7zb8w.png" /></figure><h3><strong>How you Doin’?</strong></h3><p>As we have calculated a sentiment score for each line, we are able to monitor this score throughout the course of a season.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lcwhl96JeqK5LkJIEgdbpw.png" /></figure><p>The chart above shows tracks the sentiment for Rachel and Ross throughout the first 2 seasons. Total sentiment score per episode is calculated, as the scores range in-between -1 to 1 the total will give an indication of the majority of sentiment throughout a particular episode.</p><p>Episode 104 is where Rachel gets her first paycheck, may be the cause of such positive sentiment as is episode 117 with a guest appearance from George Clooney. Ross really experiences the highs and lows throughout the first episodes, finding out he was having a boy in episode 112 before saying bye to marcel in episode 121. Before finally, both characters show a spike on episode 207, The One where Ross Finds Out and a conflicted Ross finds out Rachel has feelings for him. This may be why Ross’ overall sentiment for that episode was “muted but positive”.</p><h3>Networks</h3><p>So far we have mostly looked at out FRIENDS isolation, here we will see how they interact. Looking at how many times a character mentions another characters name the show so we can draw networks relating each character to another. The table below shows the results; read from left to right tells us that Rachel mentioned herself 187 times and mentioned Joey the most: 739 times. Read from top to bottom can be understood as Rachel mentioned Chandler 321 times, Ross mentioned him 332 times and his wife (Monica) mentioned him the most: 622.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39234ed0a528ac701b51e2284a430bed/href">https://medium.com/media/39234ed0a528ac701b51e2284a430bed/href</a></iframe><p>The table throws up some interesting findings, Rachel was mentioned the most by Ross (622, and one <a href="https://youtu.be/5-1-W-qH6Fc?t=253">cost him his marrige</a> ) and Ross was mentioned by Rachel the most: 550. Interestingly, although Monica says chandler the most, Chandler says Joey the most.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*n8mXb-sTI5AzE47KnsXiPg.gif" /><figcaption>via <a href="https://gfycat.com/gifs/search/joey+e">gfycat</a></figcaption></figure><p>The table does provide some insight but it isn’t the most ascetically pleasing way to look at the findings. So we can create a chord diagram using <a href="https://github.com/fengwangPhysics/matplotlib-chord-diagram/blob/master/matplotlib-chord.py">this fucntion</a> provided on Github. The size of the chords for each characters section represents how many times they said the connecting characters name. In other words, if you were to read the values from left to right in the table, that is what each characters portion shows. This makes it clearer just how much both Joey and Monica occupy Chandler’s mentions by looking at the pink slice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*lzaZscAGApB6JseKk9r4Eg.png" /></figure><h3>Graph and Centrality</h3><p>So we have now built a network of FRIENDS we can calculate a centrality score for each of them. Centrality aims to answer the question: <em>Who is the most important or central person in this network?</em>. Obviously this is a subjective question depending on the definition of importance. Before we define our measure of importance, we must first convert our table into a graph. We will use network x to create a directed, weighted graph using the values in the table above (stored in network_data). Nodes are the characters and the weights are the number of mentions. We can also check the graph has been created correctly by checking the edge weights between nodes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf000a6c9bee758cc9804fd853b638a/href">https://medium.com/media/7cf000a6c9bee758cc9804fd853b638a/href</a></iframe><pre>out: {&#39;weight&#39;: 426} # yay! it matches our table</pre><p>Now we have created our graph, we calculate the <a href="https://www.youtube.com/watch?v=9vs1zSqd070">Eigenvector Centrality</a> as a measure of importance (used in Google’s page rank). This algorithm aims quantify influence of people in a social network, based on connections with important people. In this case we are defining “importance” as connections with important people. With an emphasis on links with other people, it is easy to see how this may be applied to other larger networks such as Twitter. Using “interactions” (retweets and likes) as weights, this algorithm may be able to give you the most connected accounts in a network, potentially gaining more insight than a count of the highest number of followers. Valuable information for anyone looking to gauge (or alter) public opinion.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6db85b31d4668fba5695c8cc0e998d79/href">https://medium.com/media/6db85b31d4668fba5695c8cc0e998d79/href</a></iframe><p>Networkx makes life easy, apply the eigenvector_centrality_numpy method and define the weights to calculate the scores for each node. The result in order of importance is shown below. I was surprised upon initially looking at the results, however when I thought about the measure it started to make sense. I think Joey could be seen as the glue of the group, always interacting with the other characters. To see Ross and Rachel at the lower end isn&#39;t entirely surprising given that they occupy most of each others time. This post hasn&#39;t been great for Phoebe 🙁 ​ .These results are subjective, as as is the interpretation and I would love to hear what you think about the centrality scores.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9798706a971dc2b062ff070da97f8e31/href">https://medium.com/media/9798706a971dc2b062ff070da97f8e31/href</a></iframe><p>I hope you enjoyed this alternative view on the popular show. Whilst I understand FRIENDS may not be everyone’s cup of tea I do think this kind of analysis can be applied to almost any long running series. Maybe you could try out something similar for your favourite show and let me know what you find!</p><p>Thanks for reading 🙂</p><p><em>Originally published at </em><a href="https://quotennial.github.io/friends-analysis/"><em>https://quotennial.github.io/friends-analysis/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59dafcec19c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-one-with-all-the-friends-analysis-59dafcec19c5">The One with all the FRIENDS Analysis</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>