Home > other >  Pandas row data consolidation issues
Pandas row data consolidation issues

Time:11-27


This is on the pandas, every time my idea is to put a full stop. When it merged into a line, the full stop at the top of the word
 
For I in range (0, len (df1) :
If df2. Iloc [I] [' word ']!='. ':
The list [w] [1]. Append (df2. Iloc [I] [' word '])
The list [w] [2]. Append (df2. Iloc [I] [' word '])

The else:
W +=1
Print (list)

The above is the part I wrote a little bit of code,

CodePudding user response:

The old man have any idea

CodePudding user response:

 
Df3=pd. DataFrame (columns=[' sents', 'word_pos'])
Df3
W=0
For word in df2. Loc [: [' word ']] :
If df2. Iloc [I] [' word ']!='. ':
Df3. Iloc [w] [' word ']. Append (df2. Iloc [I] [' word '])
The else:
W +=1
Print (list)

I changed the code, it is inserted into an empty dataframe, but complains: single positional indexer is the out - of - bounds

CodePudding user response:

Create a string variable, traverse of the words with the string, until the end to stop, and to bring the empty string variable

CodePudding user response:

Ok I try, append before use wrong can't add something to the cell,
  • Related