How to create pie chart?
<p>new to Python and stuck with a pie chart.
Apologies for the complexity but I am at a lost as how to proceed ..
I  have this  dataset in the form of a dictionary (part of it)</p>

<pre><code>{'Deaths5': 94, 'Deaths10': 379, 'Deaths12': 388, 'Deaths8': 138, 'Deaths25': None,
 'IM_Deaths2': None, 'Deaths14': 511, 'Deaths1': 20535, 'Deaths23': 2643, 'Deaths6': 62,
 'IM_Deaths1': 4349, 'Deaths17': 1036, 'Deaths18': 1234, 'Sex': '2', 'Deaths11': 358, 'Deaths22': 1708,
 'Deaths21': 1922, 'IM_Frmat': '08', 'SubDiv': '', 'Deaths15': 600, 'Deaths4': 157, 'Admin1': '',
 'IM_Deaths3': None, 'Deaths19': 1125, 'Deaths24': None, 'Frmat': '01', 'Deaths20': 1602, 'Deaths3': 350,
 'Year': '1964', 'Deaths7': 149, 'Deaths9': 311, 'Deaths26': 33, 'Country': '2150',
 'Deaths16': 932, 'Deaths13': 454, 'Deaths2': 4349, 'IM_Deaths4': None, 'Cause': 'A000', 'List': '07A' .......
</code></pre>

<p>I need to generate a pie chart that shows the latest year - 2013,
and shows the top 8 causes of death code 'Cause' from field 'Deaths1'</p>

<p>So to sum it up:</p>

<p>So for example  the data should be filtered as</p>

<pre><code>Year    CAUSE    Top8
2013     A000    5000
2013     A411    400
2013     A50     200
.....
</code></pre>

<p>and then shown as a pie chart with anything after the top 8 treated as 'other'</p>

<p>I could do this very easily with SQL but with Python...I am not sure.</p>

<p>Full disclosure, I'm a member of the ZingChart team.</p>

<p>You can use <a href="https://www.zingchart.com/" rel="nofollow">ZingChart</a> for free to accomplish this. I'm not sure if you were looking for the answer to include how to parse the dictionary or just the data visualization portion. With some simple attributes we can display the data in a legible manner. From there we can hover nodes to get more information about the node and we can click on the legend to remove a node from the graph. This will re calculate the percentage taken up be each node amongst remaining, non hidden nodes.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var myConfig = {
 	type: 'pie',
 	title:{
 	  text: '2013 Deaths',
 	  adjustlayout: true
 	},
 	legend:{
 	  toggleAction: 'remove'
 	},
 	plot:{
 	  valueBox:{ // hard label
 	    placement:'out'
 	  }
 	},
 	tooltip:{ // for node hover
 	  text:'%t: Had %v deaths in 2013'
 	},
	series: [
		{
			values: [5000],
			text: 'A000'
		},
		{
			values: [400],
			text: 'A411'
		},
		{
			values: [200],
			text: 'A00'
		},
		{
			values: [900],
			text: 'Other'
		}
	]
};

zingchart.render({ 
	id: 'myChart', 
	data: myConfig, 
	height: '100%', 
	width: '100%' 
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>html, body {
	height:100%;
	width:100%;
	margin:0;
	padding:0;
}
#myChart {
	height:100%;
	width:100%;
	min-height:150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
	&lt;head&gt;
	&lt;!--Assets will be injected here on compile. Use the assets button above--&gt;
		&lt;script src= "https://cdn.zingchart.com/zingchart.min.js"&gt;&lt;/script&gt;
		&lt;script&gt; zingchart.MODULESDIR = "https://cdn.zingchart.com/modules/";
		ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9","ee6b7db5b51705a13dc2339db3edaf6d"];&lt;/script&gt;
	&lt;!--Inject End--&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div id="myChart"&gt;&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

python python-3.x dictionary charts pie-chart