mathew :
data = {'pop': [2.0, 3.0, 4.0],'county':['jpy','jpy','jpy']}
df = pd.DataFrame(data)
I want to change the column('pop') name dynamically with the unique value in other column. I do not want to hard code the column value. I'm trying something like below but it's throwing an error.
value = df.county.unique()
df.rename(columns={'pop': str(value)}, inplace=True)
Expected output:
df = jpy county
2.0 jpy
3.0 jpy
4.0 jpy
kederrac :
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=386990&siteId=1