最近,我需要分析一个以列和行形式存储数据的网站的数据。 主行中的每个列单元格都与左上角的单元格(标题)相关。 但是,每个标题下面都有两个单元格(后续两行中的第一个单元格)。 一个包含标题的描述;另一个包含与标题相关的内容标签。
不幸的是,该网页未设置为允许我使用 JMP File>Internet Open 导入为 .html 或 .txt。 所以,我剪切并粘贴到 Excel 中。 JMP 系统工程师同事 Olivia Lippincott @O_Lippincott ,说对于她遇到的Excel用户,Excel格式(图1)很常见,她经常帮他们清理。
需要将多行拆分为单独的列。 我们就是这样做的。
首先,我们打开Excel文件到JMP .
Figure 1: Table of Excel data imported into JMPFigure 1: Table of Excel data imported into JMPFigure 1: Table of Excel data imported into JMPFigure 1: Table of Excel data imported into JMP图 1:导入 JMP 的 Excel 数据表其次,我们创建了一个名为 Title Type 的新列,其中 Column Properties Data Type = Numeric 和 Modeling Type = Nominal。 我们通过在 Title Type 列的前三个单元格中键入 1、2 和 3,突出显示它们,然后选择 FILL>REPEAT SEQUENCE TO END OF TABLE,以重复序列 1、2、3 填充单元格。 这为我们提供了一个 ID 列,用于标识 Title 字段模式。
Figure 2: Add Title Type to identify the pattern 1-3 for the three Title TypesFigure 2: Add Title Type to identify the pattern 1-3 for the three Title TypesFigure 2: Add Title Type to identify the pattern 1-3 for the three Title TypesFigure 2: Add Title Type to identify the pattern 1-3 for the three Title Types图 2:添加标题类型以识别三种标题类型的模式 1-3第三,我们拆分表 (TABLE>SPLIT) 以将 Title Type 2 和 Title Type 3 分成两个不同的列。 我也将脚本保存到数据表中,以供参考。
Figure 3: Splitting Title Column into 3 columns by Title TypeFigure 3: Splitting Title Column into 3 columns by Title TypeFigure 3: Splitting Title Column into 3 columns by Title TypeFigure 3: Splitting Title Column into 3 columns by Title Type图 3:按标题类型将标题列拆分为 3 列
Figure 4: JSL script to split Title Column into 3 columns by Title TypeFigure 4: JSL script to split Title Column into 3 columns by Title TypeFigure 4: JSL script to split Title Column into 3 columns by Title TypeFigure 4: JSL script to split Title Column into 3 columns by Title Type图 4:将标题列按标题类型拆分为 3 列的 JSL 脚本
第四,我们移动了一些列,将标题 Title Type 2 重命名为 Description,将 Title Type 3 重命名为 Tags。最后,我们摆脱了领导标签:通过重新编码标记列上的文本标签:使用“重新编码”红色小三角下方的“替换字符串”选项添加到空白区域。
Figure 5: Accessing Column Recode using Replace StringFigure 5: Accessing Column Recode using Replace StringFigure 5: Accessing Column Recode using Replace StringFigure 5: Accessing Column Recode using Replace String图 5:使用替换字符串访问列重新编码
Figure 6: Using Recode to replace consistent Tags: text found in each cell in a columnFigure 6: Using Recode to replace consistent Tags: text found in each cell in a columnFigure 6: Using Recode to replace consistent Tags: text found in each cell in a columnFigure 6: Using Recode to replace consistent Tags: text found in each cell in a column图 6:使用 Recode 替换一致的标签:在列中的每个单元格中找到的文本
Figure 7. Final Videos Table ready for JMP analysisFigure 7. Final Videos Table ready for JMP analysisFigure 7. Final Videos Table ready for JMP analysisFigure 7. Final Videos Table ready for JMP analysis图 7。 准备好进行 JMP 分析的最终视频表
使用 JMP 的整个清理过程大约需要 1 分钟。 也许这些步骤将在您自己的数据清理和准备过程中为您提供帮助。