python - Filling missing lines with "nan" with pandas reindex -


thanks jeff, find missing lines in file data structure , fill missing lines.

however, filled missing lines in output show "2013-07-01 00:00:00,,,,,,,,,,,,,,,,,,", not nan. fill "nan" or "nan" inside of commas.

my code is:

filin = datapath + 'skp_aws_min_qc_10001_2013.07-09.dat' pd.set_option('max_rows',10) data=pd.read_csv(filin,sep='#',index_col=[1],parse_dates=[1]) print data index = pd.date_range('2013-07-01 00:00:00','2013-09-30 23:59:00',freq="t") df = data sk_f = df.reindex(index) print sk_f sk_f.to_csv("sample1.csv") 

as long know information reindex function, missing holes should filled (default "nan"). can't find reason why missing hole in result files not filled.

any idea or comment appreciated.

thank you, isaac

it has nothing reindex(), when to_csv, provide string missing values if don't want them show blank spaces. df.to_csv('temp.csv',na_rep='nan') trick.

if not provided, na_rep= defaults ''


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -