这是我的dataframe df中的文本,其中有一个名为'problem_note_text'的文本列
SSCIssue:注意分配器故障执行检查/分配器故障/要求商店取出纸币分配器并将其设置回/仍然错误消息说前门打开/因此CE attn reqContact详细信息 - Olivia taber 01159063390/7 am-11pm
df$problem_note_text <- tolower(df$problem_note_text)
df$problem_note_text <- tm::removeNumbers(df$problem_note_text)
df$problem_note_text<- str_replace_all(df$problem_note_text, " ", "") # replace double spaces with single space
df$problem_note_text = str_replace_all(df$problem_note_text, pattern = "[[:punct:]]", " ")
df$problem_note_text<- tm::removeWords(x = df$problem_note_text, stopwords(kind = 'english'))
Words = all_words(df$problem_note_text, begins.with=NULL)
Run Code Online (Sandbox Code Playgroud)
现在有一个数据框,其中包含一个单词列表,但有一些单词
"Failureperformed"
需要分成两个有意义的词,比如
"失败""表演".
我该怎么做呢,dataframe这个词也包含像
"im","h"
哪些没有意义,必须删除,我不知道如何实现这一点.
我已将 CSV 文件导入到 R 中的数据框中,其中一列包含文本。
我想对文本进行分析。我该怎么做?
我尝试制作一个仅包含文本列的新数据框。
OnlyTXT= Txtanalytics1 %>%
select(problem_note_text)
View(OnlyTXT).
Run Code Online (Sandbox Code Playgroud) 我试图根据条件组合火花数据框中的多行:
这是我拥有的数据帧(df):
|username | qid | row_no | text |
---------------------------------
| a | 1 | 1 | this |
| a | 1 | 2 | is |
| d | 2 | 1 | the |
| a | 1 | 3 | text |
| d | 2 | 2 | ball |
Run Code Online (Sandbox Code Playgroud)
我希望它看起来像这样
|username | qid | row_no | text |
---------------------------------------
| a | 1 | 1,2,3 | This is text|
| b | 2 …Run Code Online (Sandbox Code Playgroud) 我正在尝试一个简单的代码,在索引之后将数据框中的分类变量折叠为二进制类,目前我的列有3个类 - "A","B","C"我正在编写一个简单的if else语句来折叠类
def condition(r):
if (r.wo_flag=="SLM" or r.wo_flag=="NON-SLM"):
r.wo_flag="dispatch"
else:
r.wo_flag="non_dispatch"
return r.wo_flag
df_final=df_new.map(lambda x: condition(x))
Run Code Online (Sandbox Code Playgroud)
它不工作它不理解其他条件
|MData|Recode12|Status|DayOfWeekOfDispatch|MannerOfDispatch|Wo_flag|PlaceOfInjury|Race|
M| 11| M| 4| 7| C| 99| 1 |
M| 8| D| 3| 7| A| 99| 1 |
F| 10| W| 2| 7| C| 99| 1 |
M| 9| D| 1| 7| B| 99| 1 |
M| 8| D| 2| 7| C| 99| 1 |
Run Code Online (Sandbox Code Playgroud)
这是样本数据
dataframe ×2
pyspark ×2
r ×2
apache-spark ×1
if-statement ×1
pyspark-sql ×1
stemming ×1
string-split ×1