python 2.7 - Dtype changing when setting a column as an index -


i reindexing files multiple folders. file looks this:

combined   percent 0101       50 0102       25 0104       25 

i use code create new index union of indexes of files in folder:

import pandas pd glob import glob   folders=(r'c:\pathway_to_folders') folder in os.listdir(folders):      path=os.path.join(folders,folder)     filenames=glob(os.path.join(path+'/*.csv'))     def rfile(fn):         return pd.read_csv(fn, dtype='str', index_col=0)     dfs = [rfile(fn) fn in filenames]     idx = dfs[0].index     in range(1, len(dfs)):         idx = idx.union(dfs[i].index)     print idx 

when set column combined index column, dfs looks this:

combined   percent 101        50 102       25 104       25 

is there way keep formatting index same original column, or manipulate code not have set index possibly?

i believe still long standing bug can't set dtype , specify same column index column, have secondary step:

def rfile(fn):     return pd.read_csv(fn, dtype=str).set_index('combined') 

Comments