Rename a single pandas DataFrame column without knowing column name

Should work: drugInfo.rename(columns = {list(drugInfo)[1]: ‘col_1_new_name’}, inplace = True) Example: In [18]: df = pd.DataFrame({‘a’:randn(5), ‘b’:randn(5), ‘c’:randn(5)}) df Out[18]: a b c 0 -1.429509 -0.652116 0.515545 1 0.563148 -0.536554 -1.316155 2 1.310768 -3.041681 -0.704776 3 -1.403204 1.083727 -0.117787 4 -0.040952 0.108155 -0.092292 In [19]: df.rename(columns={list(df)[1]:’col1_new_name’}, inplace=True) df Out[19]: a col1_new_name c 0 -1.429509 -0.652116 0.515545 … Read more

Showing renames in hg status?

There are several ways to do this. Before you commit, you can use hg diff –git to show what was renamed: $ hg diff –git diff –git a/theTest.txt b/aTest.txt rename from theTest.txt rename to aTest.txt Note that this only works if you used hg mv, hg rename, or mv and hg addremove –similarity 100. After … Read more

windows batch file rename

Use REN Command Ren is for rename ren ( where the file is located ) ( the new name ) example ren C:\Users\&username%\Desktop\aaa.txt bbb.txt it will change aaa.txt to bbb.txt Your code will be : ren (file located)AAA_a001.jpg a001.AAA.jpg ren (file located)BBB_a002.jpg a002.BBB.jpg ren (file located)CCC_a003.jpg a003.CCC.jpg and so on IT WILL NOT WORK IF … Read more

Renaming TFS2010 Team Project

In all: No, it can’t be done. Your only shot is to create a new Team Project named as you ‘d like and then move everything to it. This involves serious work done by hand. After that, you can’t erase your old TeamProject – you will loose the history. You can lock it and make … Read more

Renaming applications in IIS 7.0

I recently had to do this and I think you are better off using appcmd because ,as you said, we don’t know what other changes may occur behind the scenes Example, appcmd list app APP “Default Web Site/” (applicationPool:DefaultAppPool) APP “Default Web Site/develop” (applicationPool:mypool) APP “Default Web Site/develop/xyz” (applicationPool:mypool) In my case, I did have … Read more

Python: Rename duplicates in list with progressive numbers without sorting list

My solution with map and lambda: print map(lambda x: x[1] + str(mylist[:x[0]].count(x[1]) + 1) if mylist.count(x[1]) > 1 else x[1], enumerate(mylist)) More traditional form newlist = [] for i, v in enumerate(mylist): totalcount = mylist.count(v) count = mylist[:i].count(v) newlist.append(v + str(count + 1) if totalcount > 1 else v) And last one [v + str(mylist[:i].count(v) … Read more