{"id":1027,"date":"2022-05-01T19:06:38","date_gmt":"2022-05-01T19:06:38","guid":{"rendered":"https:\/\/justinmatters.co.uk\/wp\/?p=1027"},"modified":"2022-05-01T19:07:50","modified_gmt":"2022-05-01T19:07:50","slug":"coalesce-for-combining-columns-in-pyspark","status":"publish","type":"post","link":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/","title":{"rendered":"Coalesce for Combining Columns in Pyspark"},"content":{"rendered":"<p>We can frequently find that we want to combine the results of several calculations into a single column. For instance perhaps we have various data sources with incomplete data and we want to take the best non-null value we can find from the data sources. Or perhaps we want to use some form of logic to decide which of a number of columns we can trust and select that value.<\/p>\n<p>In these cases the<strong><a href=\"https:\/\/spark.apache.org\/docs\/latest\/api\/python\/reference\/api\/pyspark.sql.functions.coalesce.html\"> coalesce <\/a><\/strong>function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark <strong><a href=\"https:\/\/spark.apache.org\/docs\/latest\/api\/python\/reference\/api\/pyspark.sql.functions.when.html\">when<\/a><\/strong> function and <strong><a href=\"https:\/\/spark.apache.org\/docs\/latest\/api\/python\/reference\/api\/pyspark.sql.Column.otherwise.html\">otherwise<\/a> <\/strong>column operator.<\/p>\n<h3>Basic Coalesce<\/h3>\n<p>Lets start with a simple example. Suppose we have a dataframe like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1042\" src=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png\" alt=\"\" width=\"590\" height=\"259\" srcset=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png 590w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01-300x132.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>We apply the following coalesce statement to it:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\ndf_simple_coalesce = df.withColumn(\r\n    'coalesced',\r\n    # a simple coalesce\r\n    coalesce(\r\n        col('col_1'),\r\n        col('col_2'),\r\n        col('col_3'),\r\n    )\r\n).withColumn(\r\n    'coalesced_with_default',\r\n    # note the use of an ending literal to ensure no nulls\r\n    coalesce(\r\n        col('col_1'),\r\n        col('col_2'),\r\n        col('col_3'),\r\n        lit(5),\r\n    )\r\n)\r\n\r\n<\/pre>\n<p>This gives us the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1030\" src=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce02-700x184.png\" alt=\"\" width=\"700\" height=\"184\" srcset=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce02-700x184.png 700w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce02-300x79.png 300w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce02-768x202.png 768w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce02.png 1027w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>OK so what has happened here? Well the coalesce function takes the first non-null value from its list of values. The withColumn command then assigns this value to our new column. We can see that the left most non-null column&#8217;s value is assigned in each case. Where we assigned a final literal, this is used to fill rows where no non-null values are found, where we did not the value remains null.<\/p>\n<h3>Using When Conditions with Coalesce<\/h3>\n<p>Rather than simply coalescing the values, lets use the same input dataframe but get a little more advanced. We add a condition to one of the coalesce terms:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# coalesce statement used in combination with conditional when statement\r\ndf_when_coalesce = df.withColumn(\r\n    'coalesced_when', \r\n    coalesce(\r\n        # no otherwise so nulls preserved\r\n        when(col('col_1') &amp;gt; 1, 5), \r\n        col('col_2'), \r\n        col('col_3')\r\n    )\r\n).withColumn(\r\n    'coalesced_when_with_otherwise', \r\n    # otherwise overwrites all nulls in col_1 \r\n    coalesce(\r\n        when(col('col_1') &amp;gt; 1, 5).otherwise(6), \r\n        col('col_2'), \r\n        col('col_3')\r\n    )\r\n)\r\n<\/pre>\n<p>This now results in:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1031\" src=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce03-700x164.png\" alt=\"\" width=\"700\" height=\"164\" srcset=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce03-700x164.png 700w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce03-300x70.png 300w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce03-768x180.png 768w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce03.png 1155w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>We see that in the column coalesced_when that where the value in col_1 was not null and exceeded 1, the value of 5 was assigned by the when statement. However in the column coalesced_when_with_otherwise the otherwise statement applies a value of 6 not just where col_1 is less than or equal to 1 but also where it was null. Care is needed when using otherwise with coalesced when functions to avoid unforseen effects.<\/p>\n<h3>Generating When Conditions with a List Comprehension<\/h3>\n<p>Occasionally we may want to generate a whole series of conditions from either a dictionary or a list. This can be useful to handle situations where we may want to be able to adjust our logic at runtime by passing a custom dictionary or list to the coalesce statement.<\/p>\n<p>Lets consider a simple case to illustrate:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# example of using a list comprehension to compile whens\r\ncolumns = &#x5B;1,2,3]\r\nwhens = &#x5B;\r\n    when(\r\n        col(f'col_{c}') == c, 0\r\n    ).otherwise(\r\n        col(f'col_{c}')\r\n    ) for c in columns\r\n]\r\n# we can also add a catchall condition to the list\r\nwhens += &#x5B;lit(-1)]\r\n\r\ndf_multiple_whens = df.withColumn(\r\n    'coalesced_whens_from_list',\r\n    coalesce(\r\n        # use star syntax to apply our list of conditions in order\r\n        *whens\r\n    )\r\n)\r\n<\/pre>\n<p>On the same dataframe as before we get:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1032\" src=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce04-700x212.png\" alt=\"\" width=\"700\" height=\"212\" srcset=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce04-700x212.png 700w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce04-300x91.png 300w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce04-768x232.png 768w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce04.png 892w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>So what is happening here? Well we set up a list of conditions that will assign a value of zero if the first column with a non-null value has a value equal to the column number. Additionally if no non-null value is found we assign a value of -1. In all other cases we take the first valid column value.<\/p>\n<p>Note that we can define both columns to be handled and conditions to be sought via the comprehension. This gives us considerable flexibility and power.<\/p>\n<p><a href=\"https:\/\/databricks-prod-cloudfront.cloud.databricks.com\/public\/4027ec902e239c93eaaa8714f173bcfc\/968100988546031\/486768497414919\/8836542754149149\/latest.html\">An example workbook demonstrating this can be found on Databricks Community Edition<\/a> or <a href=\"https:\/\/github.com\/JustinMatters\/pyspark-example-workbooks\">downloaded from my Github<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can frequently find that we want to combine the results of several calculations into a single column. For instance perhaps we have various data&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,5],"tags":[69,105,54],"class_list":["post-1027","post","type-post","status-publish","format-standard","hentry","category-data-science","category-problem-solving","tag-dataframes","tag-logic","tag-pyspark"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog<\/title>\n<meta name=\"description\" content=\"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions\" \/>\n<meta property=\"og:url\" content=\"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/\" \/>\n<meta property=\"og:site_name\" content=\"Justin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-01T19:06:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-01T19:07:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png\" \/>\n<meta name=\"author\" content=\"justinmatters\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"justinmatters\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/\"},\"author\":{\"name\":\"justinmatters\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\"},\"headline\":\"Coalesce for Combining Columns in Pyspark\",\"datePublished\":\"2022-05-01T19:06:38+00:00\",\"dateModified\":\"2022-05-01T19:07:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/\"},\"wordCount\":665,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/coalesce01.png\",\"keywords\":[\"Dataframes\",\"Logic\",\"PySpark\"],\"articleSection\":[\"Data Science\",\"Problem Solving\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/\",\"name\":\"Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/coalesce01.png\",\"datePublished\":\"2022-05-01T19:06:38+00:00\",\"dateModified\":\"2022-05-01T19:07:50+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\"},\"description\":\"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#primaryimage\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/coalesce01.png\",\"contentUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/coalesce01.png\",\"width\":590,\"height\":259},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/coalesce-for-combining-columns-in-pyspark\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coalesce for Combining Columns in Pyspark\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\",\"name\":\"Justin's Blog\",\"description\":\"Justin&#039;s Coding and Geek Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\",\"name\":\"justinmatters\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"caption\":\"justinmatters\"},\"description\":\"Data Scientist specialising in Python, PySpark, SQL and Machine Learning\",\"sameAs\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\",\"https:\\\/\\\/uk.linkedin.com\\\/in\\\/justin-matters-edinburgh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog","description":"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/","og_locale":"en_US","og_type":"article","og_title":"Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog","og_description":"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions","og_url":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/","og_site_name":"Justin&#039;s Blog","article_published_time":"2022-05-01T19:06:38+00:00","article_modified_time":"2022-05-01T19:07:50+00:00","og_image":[{"url":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png","type":"","width":"","height":""}],"author":"justinmatters","twitter_card":"summary_large_image","twitter_misc":{"Written by":"justinmatters","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#article","isPartOf":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/"},"author":{"name":"justinmatters","@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321"},"headline":"Coalesce for Combining Columns in Pyspark","datePublished":"2022-05-01T19:06:38+00:00","dateModified":"2022-05-01T19:07:50+00:00","mainEntityOfPage":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/"},"wordCount":665,"commentCount":0,"image":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#primaryimage"},"thumbnailUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png","keywords":["Dataframes","Logic","PySpark"],"articleSection":["Data Science","Problem Solving"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/","url":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/","name":"Coalesce for Combining Columns in Pyspark - Justin&#039;s Blog","isPartOf":{"@id":"https:\/\/justinmatters.co.uk\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#primaryimage"},"image":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#primaryimage"},"thumbnailUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png","datePublished":"2022-05-01T19:06:38+00:00","dateModified":"2022-05-01T19:07:50+00:00","author":{"@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321"},"description":"The coalesce function is extremely useful. It can be even more powerful when combined with conditional logic using the PySpark when and otherwise functions","breadcrumb":{"@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#primaryimage","url":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png","contentUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2022\/05\/coalesce01.png","width":590,"height":259},{"@type":"BreadcrumbList","@id":"https:\/\/justinmatters.co.uk\/wp\/coalesce-for-combining-columns-in-pyspark\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/justinmatters.co.uk\/wp\/"},{"@type":"ListItem","position":2,"name":"Coalesce for Combining Columns in Pyspark"}]},{"@type":"WebSite","@id":"https:\/\/justinmatters.co.uk\/wp\/#website","url":"https:\/\/justinmatters.co.uk\/wp\/","name":"Justin's Blog","description":"Justin&#039;s Coding and Geek Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/justinmatters.co.uk\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321","name":"justinmatters","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","caption":"justinmatters"},"description":"Data Scientist specialising in Python, PySpark, SQL and Machine Learning","sameAs":["https:\/\/justinmatters.co.uk\/wp\/","https:\/\/uk.linkedin.com\/in\/justin-matters-edinburgh"]}]}},"_links":{"self":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/comments?post=1027"}],"version-history":[{"count":11,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1027\/revisions"}],"predecessor-version":[{"id":1048,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1027\/revisions\/1048"}],"wp:attachment":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/media?parent=1027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/categories?post=1027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/tags?post=1027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}