RenameColumns
RenameColumns[tab,{col1newcol1,…}]
将 Tabular 对象 tab 中的 coli 列重命名为 newcoli.
RenameColumns[tab,{newcol1,newcol2,…}]
将 tab 中的列 i 重命名为 newcoli.
RenameColumns[renamings]
表示可应用于 Tabular 对象的 RenameColumns 的算符形式.
更多信息
- RenameColumns 通常用于更改列的名称,例如为了避免名称冲突或为了更清晰地表明意思. 还可用于将列的键添加到没有它们的 Tabular 对象.
- Possible column specifications coli in coli… include:
-
name or Key[name]or ExtendedKey[…] 列的名称 ind 整数的列索引 - If RenameColumns[tab,{newcol1,newcol2,…}] does not specify enough new column keys, then the string "Column4" will be used for the fourth column, and similarly for the rest.
- RenameColumns[tab,None] 删除 tab 中列的键.
- RenameColumns[tab,colnewcol] 等价于 RenameColumns[tab,{colnewcol}].
- RenameColumns[renamings][tab] 等价于 RenameColumns[tab,renamings].
范例
打开所有单元关闭所有单元范围 (3)
取一个 Tabular 对象:
获取没有列的键的 Tabular 对象:
添加相应的键,如果未指定,对第 列使用 "ColumnN":
用 RenameColumns[tab,None] 删除 Tabular 对象中所有列的键:
Take a Tabular object with ExtendedKey column keys:
Renaming a single outer key may change the spanning:
Rename columns to eliminate ExtendedKey:
应用 (3)
Take data for monthly ozone readings in Los Angeles:
Rename the months to Roman numerals:
Take data for monthly ozone readings in Los Angeles:
Rename columns to introduce division of months to quarters:
Take data containing information about new mothers:
Create a pivot table counting how many new mothers smoked, depending on if they used or did not use alcohol, for each mother age group:
The column keys of the pivot table were created automatically, based on the values from the "alcohol" column, and can be renamed to be more informative:
属性和关系 (4)
列本身的排列可以用 Part 来实现:
Tabular[tab,newcols] 相当于用 RenameColumns 重命名所有列的键:
文本
Wolfram Research (2025),RenameColumns,Wolfram 语言函数,https://reference.wolfram.com/language/ref/RenameColumns.html.
CMS
Wolfram 语言. 2025. "RenameColumns." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/RenameColumns.html.
APA
Wolfram 语言. (2025). RenameColumns. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/RenameColumns.html 年