0

I have a list which has two attributes and I want to seperate it into two independent variables in single new dataframe, for example:

dataframe = (var1, var2)
var1 = client, say, management, take
var2 = NN, VBP, NN, VB

My list now:

print(Grammer[:10])
[('client', 'NN'), ('say', 'VBP'), ('management', 'NN'), ('take', 'VB'), ('decission', 'NN'), ('submitted', 'VBN')]
Christian König
  • 3,437
  • 16
  • 28
  • 2
    Possible duplicate of [Transpose/Unzip Function (inverse of zip)?](https://stackoverflow.com/questions/19339/transpose-unzip-function-inverse-of-zip) – Peter Wood Oct 04 '18 at 06:42

1 Answers1

1

Use of zip + unpacking:

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')
Austin
  • 25,759
  • 4
  • 25
  • 48