pandas 数据框中列表中的小写句子

Kab*_*esh 1 python nlp pandas

我有一个如下所示的熊猫数据框。我想将所有文本转换为小写。我怎样才能在Python中做到这一点?

\n\n
\n

数据框样本

\n
\n\n
[Nah I don't think he goes to usf, he lives around here though]                                                                                                                                                                                                                          \n\n[Even my brother is not like to speak with me., They treat me like aids patent.]                                                                                                                                                                                                      \n\n[I HAVE A DATE ON SUNDAY WITH WILL!, !]                                                                                                                                                                                                                                                  \n\n[As per your request 'Melle Melle (Oru Minnaminunginte Nurungu Vettam)' has been set as your callertune for all Callers., Press *9 to copy your friends Callertune]                                                                                                                      \n\n[WINNER!!, As a valued network customer you have been selected to receivea \xc2\xa3900 prize reward!, To claim call 09061701461., Claim code KL341., Valid 12 hours only.]\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

我尝试过的

\n
\n\n
def toLowercase(fullCorpus):\n   lowerCased = [sentences.lower()for sentences in fullCorpus['sentTokenized']]\n   return lowerCased\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

我收到这个错误

\n
\n\n
lowerCased = [sentences.lower()for sentences in fullCorpus['sentTokenized']]\nAttributeError: 'list' object has no attribute 'lower'\n
Run Code Online (Sandbox Code Playgroud)\n

Mak*_*ski 5

这很容易:

df.applymap(str.lower)
Run Code Online (Sandbox Code Playgroud)

或者

df['col'].apply(str.lower)
df['col'].map(str.lower)
Run Code Online (Sandbox Code Playgroud)

好的,您已经有了按行排列的列表。然后:

df['col'].map(lambda x: list(map(str.lower, x)))
Run Code Online (Sandbox Code Playgroud)