我试图根据一些条件计算dataframe
中的值,并从series
中创建dataframe
,我不知道为什么,但它有时返回int
,有时返回float
。。。我想将所有内容规范化为int
,并在concat
之后的dataframe
中添加第一个空的column
名称
data = base.get_shuukeihyou(data_from=date_from, data_to=date_to, name=name_field)
sougou_call = data['charge'].value_counts()
data_tsunagatta = data[data.status != "gen"]
data_tsunagatta = data_tsunagatta[data_tsunagatta.status != "empty"]
data_tsunagatta = data_tsunagatta['charge'].value_counts()
apo = data[data.status == "apo"]
apo = apo['charge'].value_counts()
kontakuto = data[data.contact != "info"]
kontakuto = kontakuto[kontakuto.contact != "another"]
kontakuto = kontakuto['charge'].value_counts()
alls = pd.concat([sougou_call, data_tsunagatta, apo, kontakuto], axis=1)
alls = alls.fillna(0)
alls.columns = ["one", "two", "three", "four"]
print(alls)
还这个
one two three four
bbbb aaaa 2 0.0 0.0 0.0
john smith 1 1.0 0.0 1.0
我想要这个
name one two three four
bbbb aaaa 2 0 0 0
john smith 1 1 0 1
重置索引并使用新的^{} 方法
相关问题 更多 >
编程相关推荐