Python pandas条形图(世界各国人口)

时间:2017-04-17 16:12:38

标签: python pandas matplotlib histogram bar-chart

好的,我想做的就是制作一份关于世界各国人口的精美条形图。

pop_list = pd.read_table('country.dat', names=cols)

pop_list.dtypes
# Rank                 int64
# Country                  object
# Population           object

print(type(pop_list['Population']))
pd.Series.hist(pop_list['Population'])

给出错误: TypeError:unorderable类型:str()<浮动()

pop_list.plot.hist(['Population'],alpha=0.5)
plt.show()

制作垃圾情节,大概是'Rank',最后是

pop_list['Population'].plot().hist()

给出:     TypeError:清空'DataFrame':没有要绘制的数字数据

1 个答案:

答案 0 :(得分:1)

data回答不同后 - 需要参数var haveLoadedMetadata = stream => { let preview = document.createElement("video"); preview.srcObject = stream; return new Promise(resolve => preview.onloadedmetadata = resolve); }; var start = ms => navigator.mediaDevices.getUserMedia({video: true}) .then(stream => haveLoadedMetadata(stream) .then(() => record(stream, ms)) .then(recording => { stop(stream); video.src = link.href = URL.createObjectURL(new Blob(recording)); link.download = "recording.webm"; link.innerHTML = "Download recording"; log("Playing "+ recording[0].type +" recording:"); })) .catch(log); var record = (stream, ms) => { var rec = new MediaRecorder(stream), data = []; rec.ondataavailable = e => data.push(e.data); rec.start(); log(rec.state + " for "+ (ms / 1000) +" seconds..."); var stopped = new Promise((y, n) => (rec.onstop = y, rec.onerror = e => n(e.error || e.name))); return Promise.all([stopped, wait(ms).then(() => rec.stop())]) .then(() => data); }; var stop = stream => stream.getTracks().forEach(track => track.stop()); var wait = ms => new Promise(resolve => setTimeout(resolve, ms)); var log = msg => div.innerHTML += "<br>" + msg;

<button onclick="start(1000)">Record 1 second!</button>
<div id="div"></div><br>
<video id="video" height="120" width="160" autoplay></video>
<a id="link"></a>