Rename a column in the data frame
Changes the header name of a specified column
@param[in,out] df The data frame to modify @param[in] col_index Index of the column to rename @param[in] new_name New name for the column
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(inout) | :: | df | |||
integer, | intent(in) | :: | col_index | |||
character(len=*), | intent(in) | :: | new_name |
subroutine df_rename_column(df, col_index, new_name) type(data_frame), intent(inout) :: df integer, intent(in) :: col_index character(len=*), intent(in) :: new_name if (col_index < 1 .or. col_index > df % ncols()) error stop "column index out of range" if (.not. df % get_with_headers()) error stop "data frame has no headers to rename" call df % set_header_at_index(col_index, new_name) end subroutine df_rename_column