I have a DataFrames like shown below:
DF1 =
sID token A B C D
10 I am a f g h
10 here a g g h
10 whats a h g h
10 going a o g h
10 on a j g h
10 . a f g h
11 I am a f g h
11 foo bar a f g h
12 You are a f g h
...
Is there a way to add a counter column which counts the words (delimited by white space) to the DataFrame. That column should start counting the amount of tokens for each sID
DF2 =
sID token A B C D Counter
10 I am a f g h 0 1
10 here a g g h 2
10 whats a h g h 3
10 going a o g h 4
10 on a j g h 5
10 . a f g h 6
11 I am a f g h 0 1
11 foo bar a f g h 2 3
12 You are a f g h 0 1
...
from Counting Words in a Column in a DataFrame
No comments:
Post a Comment