簡體   English   中英

Teradata Python:如何重命名 dataframe 中的列?

[英]Teradata Python: How to rename a column in dataframe?

用戶如何重命名 teradata dataframe 中的列而不將其轉換為 Pandas dataframe?

employee = DataFrame.from_table("employee")
employee

empid       doj    dept           
13      12/04/01  ad13
7       12/02/15   ad7
7       12/02/16   ad7
5       12/02/01   ad5
5       12/02/03   ad5
15      12/04/06  ad15
15      12/04/07  ad15
15      12/04/08  ad15
5       12/02/02   ad5
7       12/02/14   ad7

讓我們將列 dept 重命名為 newdept

employee = employee.assign(drop_columns=True, doj=employee.doj, newdept=impressions.dept).  

用戶應指定要包含在修改后的數據框中的所有列。 新的 dataframe 將只有分配中提到的列。 (在分配調用中沒有給出示例用戶 ID)如果沒有給出 drop_columns=True 它將保留原始列並添加一個新名稱的列)

Here is the output of above call with the renamed column.

employee
        doj   newdept
0  12/04/01   ad13
1  12/04/07   ad15
2  12/04/08   ad15
3  12/02/14    ad7
4  12/02/16    ad7
5  12/02/01    ad5
6  12/02/02    ad5
7  12/02/03    ad5
8  12/02/15    ad7
9  12/04/06   ad15

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM