Here's a function that changes all variable names (column names) in a 
DataFrame to lower case.

function renvars_lower(df)
    vars = names(df)
    for (i,v) in enumerate(vars)
        vars[i] = lowercase(string(v))
    end
    names!(df,vars)
end

Any suggestions to improve this is welcome.

On Thursday, December 18, 2014 2:11:09 PM UTC-5, Min-Woong Sohn wrote:
>
> Thank you so much. It works beautifully.
>
> On Thursday, December 18, 2014 1:51:21 PM UTC-5, Stefan Karpinski wrote:
>>
>> Try lowercase(string(v)).
>>
>> On Thu, Dec 18, 2014 at 1:47 PM, Min-Woong Sohn <[email protected]> wrote:
>>
>>> Trying again. Here's the code that generated an error:
>>>
>>> vars = names(df)
>>>
>>> for (x, v) in enumerate(vars)
>>>    println("$x, $v", lowercase(v))
>>> end
>>>
>>> The error comes from the lowercase() function, saying that it does not 
>>> know how to handle Symbol type.
>>>
>>> On Thursday, December 18, 2014 1:15:49 PM UTC-5, Stefan Karpinski wrote:
>>>>
>>>> The variable seems to be named x not v?
>>>>
>>>> On Thu, Dec 18, 2014 at 12:55 PM, Min-Woong Sohn <[email protected]> 
>>>> wrote:
>>>>
>>>>> vars = names(df) where df is a DataFrame object and vars is an array 
>>>>> of Symbols. How do I change the elements in vars to lower case? When I did
>>>>>
>>>>> for x in vars
>>>>> println("$v")
>>>>> end
>>>>>
>>>>> it gives me an error.
>>>>>
>>>>>
>>>>> Thanks a bunch.
>>>>>
>>>>
>>>>
>>

Reply via email to