data={'GradeCol':['BVCS,105308.248']}
data1=DataFrame(data)
print(data1)
data1[['GradeColText','GradeColNum']] = pd.DataFrame([x for x in
data1.GradeCol])
#data1[['GradeColText','GradeColNum']] =
#pd.DataFrame(data1.GradeCol.values.tolist())
print(data1)
将行拆分为列 错误 ValueError:列的长度必须与键
相同预期输出
GradeColText GradeColNum
BVCS 105308.248
答案 0 :(得分:1)
试试这个?
data={'GradeCol':['BVCS,105308.248']}
df=pd.DataFrame(data)
df = pd.DataFrame(df.GradeCol.str.split(',', 1).tolist(),
columns=['GradeColText', 'GradeColNum'])
GradeColText GradeColNum
0 BVCS 105308.248
答案 1 :(得分:1)
您可以使用df.str.rsplit(expand=True)
:
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.1/vue.min.js"></script>
<div id="app">
<tile v-for="word, i in words" v-bind="word" :key="word"></tile>
</div>
<script id="tile" type="x-template">
<button :title="english">
<div class="pinyin">{{ pinyin }}</div>
<div class="eng" @mouseover="showAll = true" @mouseout="showAll = false">
<div v-if="showAll">{{ english }}</div>
<div v-else>{{ english | truncate }}</div>
</div>
</button>
</script>