我想在df列中的每個單元格的每個第n個字符之后插入換行符(> br <)。我具有以下功能,但是不知道如何調整它以遍歷df列的每一行,而不僅僅是單個文本片段。任何幫助,將不勝感激。def insertNewlines(text, lineLength): if len(text) <= lineLength: return text elif text[lineLength] != ' ': return insertNewlines(text[:], lineLength + 1) else: return text[:lineLength] + '<br>' + insertNewlines(text[lineLength + 1:], lineLength)響應user2906838:我的數據包含在名為“消息”的df中,相關列為“消息”。我嘗試了您的代碼,但是它為該行生成了語法錯誤:row[key] = return insertNewlines(text[:], lineLength + 1)抱歉,由于您之前未發布數據,請在此處找到我的df樣本:Excerpts:Can this issue be closed?The other precedences are OK; as far as I can tell... not worth messing around in the code for no demonstrable benefit.we ran into this issue on our platform. it's possibly very specific to our setup; but the patch should cause no problems for any other setup as well. simplifying this into on line is of course possible. i can't really tell you any more about it; since this issue was fixed in our local implementation about one year ago by some colleague. in preparation for our migration to the current version of shindig and opensocial 0.9 i'm revising all patches and feature additions we did over the last year and will be looking at which are worth comitting. so you can expect some more small issues in the next weeks ;)Completely non-related and probably belongs in another jira _x0089_???’ but I've added a small patch to fix two comment typos in HttpTransact (I know authorized can be spelt with an s _x0089_???’ but we don't do that anywhere else in the code)Already fixed in UIMA-1379.
添加回答
舉報
0/150
提交
取消