{"id":19026,"date":"2022-01-27T16:27:07","date_gmt":"2022-01-27T10:57:07","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=19026"},"modified":"2024-01-01T14:45:32","modified_gmt":"2024-01-01T09:15:32","slug":"nps-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/nps-python\/","title":{"rendered":"Net Promoter Score NPS Calculation Using Python"},"content":{"rendered":"\n<p>Visualizing data using python is one of the most used aspects of python. Its handy nature gives excellent ease to developers while analyzing the data. Now, this data may belong to several fields like surveys or records. They are easily analyzed using visualizing tools of python. Whenever we use these survey records to deduce some conclusion, we often use the averaging system. We take an <span style=\"text-decoration: underline;\"><strong><a href=\"http:\/\/www.pythonpool.com\/python-average-of-list\/\" target=\"_blank\" rel=\"noreferrer noopener\">average<\/a><\/strong><\/span> of the total records in this system and roam around that value for our work. However, now some other metrics are also used for visualization. One of such metrics is calculating NPS using Python. It is one of the best ways to visualize data and draw conclusions. Moreover, it gives us a better visualization of data and clarifies the data distribution better.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#What_is_Net_Promoter_Score\" >What is Net Promoter Score?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Creating_Sample_Data\" >Creating Sample Data<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Melting_Dataframe\" >Melting Dataframe<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Categorizing_Score\" >Categorizing Score<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Calculating_Net_Promoter_Score_NPS_Python\" >Calculating Net Promoter Score NPS Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Plotting_the_Data\" >Plotting the Data<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Python_NPS_in_Django\" >Python NPS in Django<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Installation\" >Installation:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#Trending_Now\" >Trending Now<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-net-promoter-score\"><span class=\"ez-toc-section\" id=\"What_is_Net_Promoter_Score\"><\/span>What is Net Promoter Score?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>On the one hand, we use the traditional method of an average system to visualize data. On the other hand, in the NP score, we first distribute the data on a scale of 10 and then calculate NP Score for that. For that, we divide it into three buckets based on their score. <\/p>\n\n\n\n<p>The best two scores, i.e., 9 and 10, are given to Promoters, then 7 and 8 are provided to Passives, and the rest of 6 are Detractors. Now, to understand it more clearly, think of a product rating. If the user rates it as 9 or 10, they are satisfied by the product and may promote that product. <\/p>\n\n\n\n<p>However, if they rate it as 7 or 8, they are just okay with the product, and they neither promote it nor degrade it. If they rate it as 6 or lower, they are unsatisfied with the product and likely to speak badly about it. <\/p>\n\n\n\n<p>Now once we get the data on the scale, we will calculate NPS Score for that. To do that, we will use the following formula:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" width=\"796\" height=\"165\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/score.jpg\" alt=\"Net Promoter Score NPS Calculation Formula\" class=\"wp-image-19029\" style=\"width:467px;height:97px\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/score.jpg 796w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/score-300x62.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/score-768x159.jpg 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><figcaption class=\"wp-element-caption\">nps python formula<\/figcaption><\/figure><\/div>\n\n\n<p>The result of the above equation ranges from 100 to -100. The smallest number is worse is the result. Now, once you have understood the concept, let&#8217;s see that on some data samples.<\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-beta monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-creating-sample-data\"><span class=\"ez-toc-section\" id=\"Creating_Sample_Data\"><\/span>Creating Sample Data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So, the dataset we will use is created with the following properties.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The dataset contains the data ranging between 0 to 10.<\/li>\n\n\n\n<li>Major part of data is 9 and 10.<\/li>\n\n\n\n<li>7 and 8 are at second in count and less than 6 are the lowest.<\/li>\n\n\n\n<li>These scores are distributed among random <a href=\"https:\/\/en.wikipedia.org\/wiki\/Country\" target=\"_blank\" rel=\"noreferrer noopener\">countries<\/a> and travelere types like business or leisure. This will help us to analyze some trends.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport matplotlib.ticker as mtick\n\ndf1 = pd.DataFrame(np.random.randint(9,11,size=(1000, 1)), columns=&#x5B;'How likely are you to reccomend the product?']) #promoters\ndf2 = pd.DataFrame(np.random.randint(7,9,size=(400, 1)), columns=&#x5B;'How likely are you to reccomend the product?']) #passives\ndf3 = pd.DataFrame(np.random.randint(0,7,size=(100, 1)), columns=&#x5B;'How likely are you to reccomend the product?']) #detractors\n\ndf = pd.concat(&#x5B;df1,df2,df3], ignore_index=True)\n\ndf&#x5B;'Country Number'] = np.random.randint(1, 6, df.shape&#x5B;0]) #assiging a random number to assign a country\ndf&#x5B;'Traveler Type Number'] = np.random.randint(1, 3, df.shape&#x5B;0]) #assigning a random number to assign a traveler type\n\n#Function to assign a country name\ndef country_name(x):\n    if x&#x5B;'Country Number'] == 1:\n        return 'United States'\n    elif x&#x5B;'Country Number'] == 2:\n        return 'Canada'\n    elif x&#x5B;'Country Number'] == 3:\n        return 'Mexico'\n    elif x&#x5B;'Country Number'] == 4:\n        return 'France'\n    elif x&#x5B;'Country Number'] == 5:\n        return 'Spain'\n    else:\n        pass\n\n#Function to assign a traveler type\ndef traveler_type(x):\n    if x&#x5B;'Traveler Type Number'] == 1:\n        return 'Business'\n    elif x&#x5B;'Traveler Type Number'] == 2:\n        return 'Leisure'\n    else:\n        pass\n\n#apply the function to the numbered columns\ndf&#x5B;'Country'] = df.apply(country_name, axis=1)\ndf&#x5B;'Traveler Type'] = df.apply(traveler_type, axis=1)\n\ndf&#x5B;&#x5B;'How likely are you to reccomend the product?', 'Country', 'Traveler Type']] #view to remove the random number columns for country and traveler type\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"781\" height=\"490\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds1.jpg\" alt=\"nps in python\" class=\"wp-image-19061\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds1.jpg 781w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds1-300x188.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds1-768x482.jpg 768w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><figcaption class=\"wp-element-caption\">nps python<\/figcaption><\/figure>\n\n\n\n<p>In the above dataset, we first imported the required library. After that, we created a data frame consisting of integers 9 and 10, and their count is 1000. Then, we created another dataframe with integers 7 and 8, and their count is 400. <\/p>\n\n\n\n<p>After that, we created a third dataframe with an integer less than seven, and their count is 100. Once we are done with creating the <span style=\"text-decoration: underline;\"><strong><a href=\"http:\/\/www.pythonpool.com\/solved-module-pandas-has-no-attribute-dataframe\/\" target=\"_blank\" rel=\"noreferrer noopener\">dataframe<\/a><\/strong><\/span>, we merge them into one dataframe using the concat() function. Then we created two columns named &#8220;country number&#8221; and &#8220;traveler type number&#8221; and assigned a random integer to each of them. Then we created two functions named &#8220;country_name()&#8221; and &#8220;traveler_type&#8221; to convert those numbers into their corresponding name. In the end, we printed the whole dataframe with desired columns.<\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-foxtrot monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-melting-dataframe\"><span class=\"ez-toc-section\" id=\"Melting_Dataframe\"><\/span>Melting Dataframe<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nmelted_df = pd.melt(frame = df, id_vars = &#x5B;'Country','Traveler Type'], value_vars = &#x5B;'How likely are you to reccomend the product?'],value_name='Score', var_name = 'Question' )\n\nmelted_df = melted_df.dropna()\n\nmelted_df&#x5B;'Score'] = pd.to_numeric(melted_df&#x5B;'Score'])\nmelted_df\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"808\" height=\"506\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds2.jpg\" alt=\"Melting Dataframe\" class=\"wp-image-19063\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds2.jpg 808w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds2-300x188.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds2-768x481.jpg 768w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><figcaption class=\"wp-element-caption\">nps python<\/figcaption><\/figure>\n\n\n\n<p>Once done with the above process, we will modify our dataframe for better visualization. To do that, we will use the <strong>melt() function <\/strong>to convert the &#8216;How likely are you to recommend the product?&#8217; column into the &#8220;Score&#8221; column and then add that question to each row. Then, we drop all the unavailable values from the <a href=\"http:\/\/www.pythonpool.com\/python-code-to-convert-a-table-to-first-normal-form\/\"><span style=\"text-decoration: underline;\"><strong>table<\/strong><\/span><\/a> using the <strong>dropna() <\/strong>method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-categorizing-score\"><span class=\"ez-toc-section\" id=\"Categorizing_Score\"><\/span>Categorizing Score<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef nps_bucket(x):\n    if x &gt; 8:\n        bucket = 'promoter'\n    elif x &gt; 6:\n        bucket = 'passive'\n    elif x&gt;= 0:\n        bucket = 'detractor'\n    else:\n        bucket = 'no score'\n    return bucket\n\nmelted_df&#x5B;'nps_bucket'] = melted_df&#x5B;'Score'].apply(nps_bucket)\n\nmelted_df\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"832\" height=\"466\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds3.jpg\" alt=\"Categorizing Score\" class=\"wp-image-19064\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds3.jpg 832w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds3-300x168.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds3-768x430.jpg 768w\" sizes=\"(max-width: 832px) 100vw, 832px\" \/><figcaption class=\"wp-element-caption\">nps python<\/figcaption><\/figure>\n\n\n\n<p>Once we create our dataset, it&#8217;s time to categorize it into promoters, detractors, and passive. For that, we created a function named nps_bucket. Then add them as the column.<\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-kilo monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-calculating-net-promoter-score-nps-python\"><span class=\"ez-toc-section\" id=\"Calculating_Net_Promoter_Score_NPS_Python\"><\/span>Calculating Net Promoter Score NPS Python<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Once we are done with categorizing the data, we will calculate NPS for each categorical country and traveler type. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ngrouped_df = melted_df.groupby(&#x5B;'Country','Traveler Type','Question'])&#x5B;'nps_bucket'].apply(lambda x: (x.str.contains('promoter').sum() - x.str.contains('detractor').sum()) \/ (x.str.contains('promoter').sum() + x.str.contains('passive').sum() + x.str.contains('detractor').sum())).reset_index()\n\ngrouped_df_sorted = grouped_df.sort_values(by='nps_bucket', ascending=True)\ngrouped_df_sorted\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"821\" height=\"447\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds5.jpg\" alt=\"Net Promoter Score NPS Python\" class=\"wp-image-19065\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds5.jpg 821w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds5-300x163.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/ds5-768x418.jpg 768w\" sizes=\"(max-width: 821px) 100vw, 821px\" \/><figcaption class=\"wp-element-caption\">nps python<\/figcaption><\/figure>\n\n\n\n<p><a href=\"http:\/\/www.pythonpool.com\/pythons-itertools-groupby\/\" target=\"_blank\" rel=\"noopener\"><\/a>We use the groupby() function, which groups the data based on &#8216;Country&#8217;, &#8216;Traveler Type&#8217;, &#8216;Question&#8217;. Then we calculated the NPS for each group.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-plotting-the-data\"><span class=\"ez-toc-section\" id=\"Plotting_the_Data\"><\/span>Plotting the Data<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>It is time to chart the data using the seaborn and matplotlib library.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nsns.set_style(&quot;whitegrid&quot;)\nsns.set_context(&quot;poster&quot;, font_scale = 1)\nf, ax = plt.subplots(figsize=(15,7))\n\nsns.barplot(data = grouped_df_sorted, x = 'nps_bucket',y='Country',hue='Traveler Type',ax=ax)\nax.set(ylabel='',xlabel='', title = 'NPS Score by Country and Traveler Type')\nax.set_xlim(0,1)\nax.xaxis.set_major_formatter(plt.NullFormatter())\nax.legend()\n\n#data labels\nfor p in ax.patches:\n    ax.annotate(&quot;{:.0f}&quot;.format(p.get_width()*100),\n                (p.get_width(), p.get_y()),\n                va='center', \n                xytext=(-35, -18), #offset points so that the are inside the chart\n                textcoords='offset points', \n                color = 'white')\n    \nplt.tight_layout()\nplt.savefig('NPS by Country.png')\nplt.show()\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"822\" height=\"372\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/chart.jpg\" alt=\"NPS Python score by country\" class=\"wp-image-19066\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/chart.jpg 822w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/chart-300x136.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/chart-768x348.jpg 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><figcaption class=\"wp-element-caption\">nps python<\/figcaption><\/figure>\n\n\n\n<p>So, in the above chart, we can see that we got the graph for each net promoter score. This chart gives us information about how much a person likes to suggest travel to their known ones or how do they rate a flight.<\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-lima monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method.webp 1200w \" alt=\"[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\">[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-nps-in-django\"><span class=\"ez-toc-section\" id=\"Python_NPS_in_Django\"><\/span>Python NPS in Django<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This library in <span style=\"text-decoration: underline;\"><strong><a href=\"http:\/\/www.pythonpool.com\/how-instagram-is-using-django-and-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Django<\/a><\/strong><\/span> works as similar as the above described. However, we need not code this much to take it into use. We need to use the <strong>net_promoter_score() <\/strong>function to calculate it. Let&#8217;s see it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-installation\"><span class=\"ez-toc-section\" id=\"Installation\"><\/span>Installation:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install django-nps<\/code><\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n UserScore.objects.filter(timestamp__month=12).net_promoter_score()\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So, today in this article, we learned how to calculate Net Promoter Score for a dataset today. We have seen the data distribution while figuring out how they represent the data easily. <\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-delta monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-2\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Now\"><\/span>Trending Now<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 11, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal.webp 1200w \" alt=\"[Solved] runtimeerror: cuda error: invalid device ordinal\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Solved] runtimeerror: cuda error: invalid device ordinal<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method.webp 1200w \" alt=\"[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>Visualizing data using python is one of the most used aspects of python. Its handy nature gives excellent ease to developers while analyzing the data. &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Net Promoter Score NPS Calculation Using Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/nps-python\/#more-19026\" aria-label=\"More on Net Promoter Score NPS Calculation Using Python\">Read more<\/a><\/p>\n","protected":false},"author":25,"featured_media":19422,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[296,4],"tags":[4773,4771,4775,4777,4776,4772,4770],"class_list":["post-19026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-programs","tag-how-to-find-user-of-chat-in-nps-in-python","tag-how-to-find-users-in-nps-chat-in-python","tag-net-promoter-score","tag-net-promoter-score-django","tag-net-promoter-score-python","tag-nps-python-grades","tag-python-nps","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Net Promoter Score NPS Calculation Using Python - Python Pool<\/title>\n<meta name=\"description\" content=\"In this article, we will see how can we calculate Net Promoter Score using python for a dataset and visualize data while calculation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/nps-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Net Promoter Score NPS Calculation Using Python\" \/>\n<meta property=\"og:description\" content=\"Visualizing data using python is one of the most used aspects of python. Its handy nature gives excellent ease to developers while analyzing the data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/nps-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-27T10:57:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-01T09:15:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Rishav Raj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rishav Raj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/\"},\"author\":{\"name\":\"Rishav Raj\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4\"},\"headline\":\"Net Promoter Score NPS Calculation Using Python\",\"datePublished\":\"2022-01-27T10:57:07+00:00\",\"dateModified\":\"2024-01-01T09:15:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/\"},\"wordCount\":821,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp\",\"keywords\":[\"how to find user of chat in nps in python\",\"how to find users in nps chat in python\",\"Net Promoter Score\",\"Net Promoter Score django\",\"Net Promoter Score python\",\"nps python grades\",\"python nps\"],\"articleSection\":[\"How to\",\"Programs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/nps-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/nps-python\/\",\"name\":\"Net Promoter Score NPS Calculation Using Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp\",\"datePublished\":\"2022-01-27T10:57:07+00:00\",\"dateModified\":\"2024-01-01T09:15:32+00:00\",\"description\":\"In this article, we will see how can we calculate Net Promoter Score using python for a dataset and visualize data while calculation.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/nps-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp\",\"width\":1200,\"height\":628,\"caption\":\"nps python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/nps-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Net Promoter Score NPS Calculation Using Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4\",\"name\":\"Rishav Raj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/77d441cf39fc8183322bfc1dcaf04be5c1fd429574820606cccac81fd8e8749a?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/77d441cf39fc8183322bfc1dcaf04be5c1fd429574820606cccac81fd8e8749a?s=96&d=wavatar&r=g\",\"caption\":\"Rishav Raj\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Net Promoter Score NPS Calculation Using Python - Python Pool","description":"In this article, we will see how can we calculate Net Promoter Score using python for a dataset and visualize data while calculation.","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:\/\/www.pythonpool.com\/nps-python\/","og_locale":"en_US","og_type":"article","og_title":"Net Promoter Score NPS Calculation Using Python","og_description":"Visualizing data using python is one of the most used aspects of python. Its handy nature gives excellent ease to developers while analyzing the data.","og_url":"https:\/\/www.pythonpool.com\/nps-python\/","og_site_name":"Python Pool","article_published_time":"2022-01-27T10:57:07+00:00","article_modified_time":"2024-01-01T09:15:32+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp","type":"image\/webp"}],"author":"Rishav Raj","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Rishav Raj","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/nps-python\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/"},"author":{"name":"Rishav Raj","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4"},"headline":"Net Promoter Score NPS Calculation Using Python","datePublished":"2022-01-27T10:57:07+00:00","dateModified":"2024-01-01T09:15:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/"},"wordCount":821,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp","keywords":["how to find user of chat in nps in python","how to find users in nps chat in python","Net Promoter Score","Net Promoter Score django","Net Promoter Score python","nps python grades","python nps"],"articleSection":["How to","Programs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/nps-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/nps-python\/","url":"https:\/\/www.pythonpool.com\/nps-python\/","name":"Net Promoter Score NPS Calculation Using Python - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp","datePublished":"2022-01-27T10:57:07+00:00","dateModified":"2024-01-01T09:15:32+00:00","description":"In this article, we will see how can we calculate Net Promoter Score using python for a dataset and visualize data while calculation.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/nps-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/nps-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/nps-python\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2022\/01\/nps-python.webp","width":1200,"height":628,"caption":"nps python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/nps-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Net Promoter Score NPS Calculation Using Python"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4","name":"Rishav Raj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/77d441cf39fc8183322bfc1dcaf04be5c1fd429574820606cccac81fd8e8749a?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/77d441cf39fc8183322bfc1dcaf04be5c1fd429574820606cccac81fd8e8749a?s=96&d=wavatar&r=g","caption":"Rishav Raj"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/19026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=19026"}],"version-history":[{"count":18,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/19026\/revisions"}],"predecessor-version":[{"id":31552,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/19026\/revisions\/31552"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/19422"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=19026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=19026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=19026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}