Home > other >  Pandas traversal problem and index.
Pandas traversal problem and index.

Time:12-04

 
For word in df2. Loc [: [' word ']] : # traversal word all cells in the column of
For I in range (len (df2 loc [: [' word ']])) :
If the STR (df2 iloc [I] [3])=='& lt; p> 'and STR (df2 iloc [I + 1] [3]).='& lt; p> ': #, using iloc index determine whether inside a cell for & lt; p> ,
P +=1
If df2. Iloc [I] [3].='. ': # judge whether to end inside the cell,
Words +=STR (df2 iloc [I] [3]) + "
Poss +=STR (df2 iloc [I] [5]) + "
Prot +=STR (df2 iloc [I] [4]) + "


On the first code, write their own traversal run slowly, with a 100 m TXT takes about 100 minutes, please use iterrows (), itertuples (), the iteritems (), these three methods traversal, and the index to the elements within a cell? Specific how to operate,

CodePudding user response:

Have a brother to prompt not ~

CodePudding user response:

Given data and to achieve the purpose of, there is no need to feel your inner cycle

CodePudding user response:


This is my data, the data is by the sentence is cut into the text of the words and symbols, and the corresponding part of speech (column 4) and (3) the word prototype, the first thing I put their combined into sentences, good to assign the part of speech of each word and prototypes, and assign id for each sentence, I make the effect of the following

CodePudding user response:

Df2 is what look like

CodePudding user response:


This is df2

CodePudding user response:

Feeling this should is like this:
For I in df2. Index:
Df2. Iloc [I] [columns]

CodePudding user response:

You can use the iteritems () this kind of method, brother this code I didn't understand what you mean,
  • Related