Posts: 212
Threads: 25
Joined: Aug 2019
(Oct-29-2019, 03:42 PM)zhujp98 Wrote: # Import pandas library
import pandas as pd
# initialize list of lists
data = [['tom', 10], ['nick', 15], ['juli', 14]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['Name', 'AGE'])
I want to change on of the field AGE to age, keep Name unchanged .
How Can I do it?
Thanks,
Jeff
Hi!
If I understand correctly, it is you who is creating the columns and giving the names of the columns with the line:
df = pd.DataFrame(data, columns = ['Name', 'AGE'])
so have you tried changing that line to:
df = pd.DataFrame(data, columns = ['Name', 'age'])
All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Posts: 212
Threads: 25
Joined: Aug 2019
(Oct-29-2019, 04:11 PM)zhujp98 Wrote: I want to change one of columns to lower case.
Hi again!
Then maybe you could use something like:
df['AGE'].str.lower()
and if it is for all the columns, you could use something like:
data.columns = [x.lower() for x in data.columns]
I have based my answer on these:
https://stackoverflow.com/questions/2224...ing-values
https://stackoverflow.com/questions/1972...-lowercase
All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs