1

In a pandas data structure, how can I reference one column when dealing with another column?

for example using this data structure

               word  pos  neg  unsup
0         poker-fac    1    1      1
1           giggler    1    1      1
2           pre-cod    1    1      1
3       single-hand    1    1      1
4      correctly.it    1    1      1

can I use pd["word"] when addressing pd["pos"] in such as way that it would apply to every row?

JoshAsh
  • 37
  • 8

1 Answers1

1

You can use:

df['pos'] = df['word'].str.count('g')
Hamzah
  • 8,175
  • 3
  • 19
  • 43