{"id":129417,"date":"2022-11-02T18:44:10","date_gmt":"2022-11-02T18:44:10","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=857322"},"modified":"2022-11-02T18:44:10","modified_gmt":"2022-11-02T18:44:10","slug":"how-to-strip-one-set-of-double-quotes-from-strings-in-python","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/11\/02\/how-to-strip-one-set-of-double-quotes-from-strings-in-python\/","title":{"rendered":"How to Strip One Set of Double Quotes from Strings in Python"},"content":{"rendered":"\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-top\" data-payload=\"{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;857322&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;1&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}\">\n<div class=\"kksr-stars\">\n<div class=\"kksr-stars-inactive\">\n<div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\"> 5\/5 &#8211; (1 vote) <\/div>\n<\/div>\n<h2 class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">Problem Formulation and Solution Overview<\/h2>\n<p>When working with data, you may encounter a string or list of strings containing two (2) double quotes. This article shows you how to remove one set of these double quotes.<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity wp-embed-aspect-16-9 wp-has-aspect-ratio\"\/>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f4ac.png\" alt=\"\ud83d\udcac\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Question<\/strong>: How would we write code to remove the extra set of double quotes<em>?<\/em><\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">We can accomplish this task by one of the following options:<\/p>\n<ul type=\"video\" class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<li><strong>Method <\/strong>1: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-startswith\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-startswith\/\" target=\"_blank\"><code>startswith()<\/code><\/a>, <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-endswith\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-endswith\/\" target=\"_blank\"><code>endswith()<\/code><\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\"><code>slicing<\/code><\/a><\/li>\n<li><strong>Method <\/strong>2: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-regex\/\" target=\"_blank\"><code>regex<\/code><\/a> <\/li>\n<li><strong>Method <\/strong>3: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" target=\"_blank\"><code>replace()<\/code><\/a><\/li>\n<li><strong>Method 4<\/strong>: Use <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\"><code>list()<\/code><\/a><\/li>\n<li>Method 5: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a><\/li>\n<\/ul>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Method 1: Use startswith() and endswith()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-startswith\/\" target=\"_blank\"><code>startswith()<\/code><\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-endswith\/\" target=\"_blank\"><code>endswith()<\/code><\/a> in conjunction with <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\"><code>slicing<\/code><\/a> to remove one set of double quotes from a string.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"3-4\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">web_name = '\"\"The Finxter Acadcemy\"\"' if web_name.startswith('\"') and web_name.endswith('\"'): web_name = web_name[1:-1]\nprint(web_name)<\/pre>\n<p>The first line in the above code snippet declares a string containing two (2) sets of double quotes and saves this to the variable <code>web_name<\/code>.<\/p>\n<p>The following line calls the <code><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/if-then-else-in-one-line-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/if-then-else-in-one-line-python\/\" target=\"_blank\">if<\/a><\/code> statement with the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-startswith\/\" target=\"_blank\"><code>startswith()<\/code><\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-endswith\/\" target=\"_blank\"><code>endswith()<\/code><\/a> functions. Both functions are passed the argument (<code>'\"'<\/code>). <\/p>\n<p>This statement checks to see if <code>web_name <\/code>starts with and ends with the above argument. If true, the code moves to the next line and, using <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\"><code>slicing<\/code><\/a>, removes the specified character. <\/p>\n<p>The results are output to the terminal.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>\"The Finxter Acadcemy\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube\"><a href=\"https:\/\/blog.finxter.com\/how-to-strip-one-set-of-double-quotes-from-strings-in-python\/\"><img decoding=\"async\" src=\"https:\/\/blog.finxter.com\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-UkcLQxzPA4%2Fhqdefault.jpg\" alt=\"YouTube Video\"><\/a><figcaption><\/figcaption><\/figure>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Method 2: Use Regex<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">You can use the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-regex\/\" target=\"_blank\"><code>regex<\/code><\/a> method <code><a href=\"https:\/\/blog.finxter.com\/python-regex-sub\/\" data-type=\"post\" data-id=\"5861\" target=\"_blank\" rel=\"noreferrer noopener\">re.sub()<\/a><\/code> to remove one set of double quotes from a string.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import re msg = '\"\"Boost Your Python Skills\"\"'\nmsg = re.sub(r'^\"|\"$', '', msg)\nprint(msg )<\/pre>\n<p>The first line in the above code snippet imports the <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.python.org\/3\/library\/re.html\" data-type=\"URL\" data-id=\"https:\/\/docs.python.org\/3\/library\/re.html\" target=\"_blank\"><code>re<\/code><\/a> library. This allows access to and manipulation of strings to extract the desired result.<\/p>\n<p>The following line declares a string containing two (2) sets of double quotes and saves this to the variable <code>msg<\/code>.<\/p>\n<p>The next line uses <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex-sub\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-regex-sub\/\" target=\"_blank\"><code>re.sub()<\/code><\/a> to search this string for any occurrences of double quotes, removes the same and saves the result back to <code>msg<\/code>. This overwrites the original string. <\/p>\n<p>The results are output to the terminal.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>\"Boost Your Python Skills\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Another option is to use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex-sub\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-regex-sub\/\" target=\"_blank\"><code>re.sub()<\/code><\/a> and pass this function two (2) arguments: <\/p>\n<ul>\n<li>the string to replace and <\/li>\n<li>the string to replace it with.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">msg = '\"\"Boost Your Python Skills\"\"'\nmsg = re.sub('\"\"', '\"', msg)\nprint(msg)<\/pre>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>\"Boost Your Python Skills\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube\"><a href=\"https:\/\/blog.finxter.com\/how-to-strip-one-set-of-double-quotes-from-strings-in-python\/\"><img decoding=\"async\" src=\"https:\/\/blog.finxter.com\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3MtrUf81k6c%2Fhqdefault.jpg\" alt=\"YouTube Video\"><\/a><figcaption><\/figcaption><\/figure>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Method 3: Use replace()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-regex\/\" target=\"_blank\"><\/a><code><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" target=\"_blank\"><code>replace()<\/code><\/a><\/code> to remove one set of double quotes from a string.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mission = '\"\"Boost Collective Intelligence\"\"'\nmission = mission.replace('\"\"', '\"')\nprint(mission) <\/pre>\n<p>The first line in the above code snippet declares a string containing two (2) sets of double quotes and saves this to the variable <code>mission<\/code>.<\/p>\n<p>The following appends the <code>replace()<\/code> function to <code>mission<\/code> and is passed two (2) arguments: <\/p>\n<ul>\n<li>the string to replace, and <\/li>\n<li>the string to replace it with. <\/li>\n<\/ul>\n<p>The results save back to <code>mission<\/code>. The results are output to the terminal.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>\"Boost Collective Intelligence\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Method 4: Use list()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method passes a <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> containing double quotes to the <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> function. This option differs from the other options as it removes all double quotes.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">user_emails = [\"\"'alice@acme.ca', 'doug@acme.ca', 'fran@acme.ca', 'stan@acme.ca'\"\"]\nuser_emails = list(user_emails)\nprint(user_emails)\n<\/pre>\n<p>The first line in the above code contains a <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> of Finxter user&#8217;s emails with double quotes at the beginning and the end.<\/p>\n<p>This saves to <code>user_emails<\/code>.<\/p>\n<p>The following line uses a <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> and passes <code>user_emails<\/code> to it as an argument. The results save back to <code>user_emails <\/code>and are output to the terminal.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>['alice@acme.ca', 'doug@acme.ca', 'fran@acme.ca', 'stan@acme.ca']<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p class=\"has-global-color-8-background-color has-background\"><strong><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>Note<\/strong>: Converting a <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> containing double quotes to a <a href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\">list<\/a> removes all double quotes.<\/p>\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube\"><a href=\"https:\/\/blog.finxter.com\/how-to-strip-one-set-of-double-quotes-from-strings-in-python\/\"><img decoding=\"async\" src=\"https:\/\/blog.finxter.com\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqXOFngx0bQU%2Fhqdefault.jpg\" alt=\"YouTube Video\"><\/a><figcaption><\/figcaption><\/figure>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Method 5: Use Pandas<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a> to remove all double quotes from a CSV file. <\/p>\n<p>Contents of CSV file<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>Store,Category,Product,Number<br \/>\"\"Toronto\"\",\"\"Jeans\"\",\"\"10534\"\",\"\"15\"\"<br \/>\"\"Montreal\"\",\"\"Tops\"\",\"\"5415\"\",\"\"32\"\"<br \/>\"\"Ottawa\"\",\"\"Coats\"\",\"\"98341\"\",\"\"22\"\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd df = pd.read_csv('quotes.csv',header=None)\ndf.replace('\"', '', inplace=True, regex=True)\nprint(df)<\/pre>\n<p>The above example imports the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a> library. This library allows access to and manipulation of a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a> DataFrame.<\/p>\n<p>The following line reads in the CSV file, without the header row into the DataFrame, <code>df<\/code>.<\/p>\n<p>If output to the terminal, the DataFrame appears as follows:<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>Shop<\/td>\n<td>Category<\/td>\n<td>Product<\/td>\n<td>Number<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>Toronto&#8221;&#8221;<\/td>\n<td>Jeans&#8221;&#8221;<\/td>\n<td>10534&#8243;&#8221;<\/td>\n<td>15&#8243;&#8221;<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Montreal&#8221;&#8221;<\/td>\n<td>Tops&#8221;&#8221;<\/td>\n<td>5415&#8243;&#8221;<\/td>\n<td>32&#8243;&#8221;<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Ottawa&#8221;&#8221;<\/td>\n<td>Coats&#8221;&#8221;<\/td>\n<td>98341&#8243;&#8221;<\/td>\n<td>22&#8243;&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><strong>Note<\/strong>: By default, when the CSV file was imported, the beginning double quotes were removed, thus leaving the trailing double quotes.<\/p>\n<p>Next, all occurrences of trailing quotes are replaced (removed) from the DataFrame. <\/p>\n<p>The output of the modified DataFrame, <code>df<\/code> are output to the terminal.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>Shop<\/td>\n<td>Category<\/td>\n<td>Product<\/td>\n<td>Number<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>Toronto<\/td>\n<td>Jeans<\/td>\n<td>10534<\/td>\n<td>15<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Montreal<\/td>\n<td>Tops<\/td>\n<td>5415<\/td>\n<td>32<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Ottawa<\/td>\n<td>Coats<\/td>\n<td>98341<\/td>\n<td>22<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube\"><a href=\"https:\/\/blog.finxter.com\/how-to-strip-one-set-of-double-quotes-from-strings-in-python\/\"><img decoding=\"async\" src=\"https:\/\/blog.finxter.com\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-JKVy_HliQE%2Fhqdefault.jpg\" alt=\"YouTube Video\"><\/a><figcaption><\/figcaption><\/figure>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Summary<\/h2>\n<p>This article has provided five (5) ways to remove one set of double quotes from a string and all double quotes to select the best fit for your coding requirements.<\/p>\n<p>Good Luck &amp; Happy Coding!<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<h2>Programmer Humor &#8211; Blockchain<\/h2>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"280\" height=\"394\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/07\/image-31.png\" alt=\"\" class=\"wp-image-457795\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/07\/image-31.png 280w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/07\/image-31-213x300.png 213w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><figcaption><em>&#8220;Blockchains are like grappling hooks, in that it&#8217;s extremely cool when you encounter a problem for which they&#8217;re the right solution, but it happens way too rarely in real life.&#8221;<\/em> <strong>source <\/strong> &#8211; <a href=\"https:\/\/imgs.xkcd.com\/comics\/blockchain.png\" data-type=\"URL\" data-id=\"https:\/\/imgs.xkcd.com\/comics\/blockchain.png\" target=\"_blank\" rel=\"noreferrer noopener\">xkcd<\/a><\/figcaption><\/figure>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>5\/5 &#8211; (1 vote) Problem Formulation and Solution Overview When working with data, you may encounter a string or list of strings containing two (2) double quotes. This article shows you how to remove one set of these double quotes. Question: How would we write code to remove the extra set of double quotes? We [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-129417","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/129417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=129417"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/129417\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=129417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=129417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=129417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}