我有一个具有两个属性的列表,我想在一个新的数据框中将其分成两个独立的变量,例如:
dataframe = (var1, var2)
var1 = client, say, management, take
var2 = NN, VBP, NN, VB
现在我的列表:
print(Grammer[:10])
[('client', 'NN'), ('say', 'VBP'), ('management', 'NN'), ('take', 'VB'), ('decission', 'NN'), ('submitted', 'VBN')]
答案 0 :(得分:1)
使用zip
+开箱:
lst = [('client', 'NN'), ('say', 'VBP'), ('management', 'NN'), ('take', 'VB'), ('decission', 'NN'), ('submitted', 'VBN')]
var1, var2 = zip(*lst)
print(var1) # ('client', 'say', 'management', 'take', 'decission', 'submitted')
print(var2) # ('NN', 'VBP', 'NN', 'VB', 'NN', 'VBN')