2017-08-30 28 views
-1

と間違って何同定することは、2015年は、私が何をしようとしている私のコード

にDFの列を私に各国の人口を教えてくれる新しい列を作成することです、次のとおりです。

['id', 'code', 'name', 'area', 'area_land', 'area_water', 'population', 
    'population_growth', 'birth_rate', 'death_rate', 'migration_rate', 
    'created_at', 'updated_at'] 

ここでは、男です:

import pandas as pd 
import sqlite3 
import math 

con = sqlite3.connect(r'C:\Python34\factbook.db') 
facts = pd.read_sql_query('select * from facts;', con) 
facts.dropna() 
facts = facts[facts['area_land']!=0][:] 
facts = facts[facts['population']!=0][:] 

def pop_in_50(name): 
    pop=facts[facts['name']==name]['population'] 
    prec = facts[facts['name']==name]['population_growth'] 
    new_pop = pop*math.e**(35*(prec/100)) 
    return new_pop 

facts['pop_in_2050'] = facts['name'].apply(pop_in_50) 

それは、次のerrrorを与える:

ValueError: Wrong number of items passed 259, placement implies 1

+0

これはどの回線で失敗しますか? – RageCage

+0

'facts.dropna(inplace = True)' – Wen

+0

これは私のコードでは別の問題かもしれませんが、エラーは解決しません。私は次のように感じます: "間違った数のアイテムが215を渡し、配置が1を意味する" –

答えて

0

試行:

new_pop = pop.values*math.e**(35*(prec.values/100)) 
関連する問題