数据小站
数据科学成长之路

python文件读写

pandas读写
pd.read_csv/table([path,sep/delimiter,header,index_col,names,skiprows,na_values,comment,parse_dates,
keep_date_col,converters,dayfirst,date_parser,norws,iterator,chunksize,skip_footer,verbose,encoding,
squeeze,thousands])
pd.read_csv(”,header=None,names=[..],index_col=[]) ==>pd.read_table(..,sep=”)
pd.read_talbe(”,sep=’\s+’,[skiprows=[…],])
chunker=pd.read_csv(”,chunksize=1000) ==>可迭代的TextPraser对象
df.to_csv(”,[sep=”,na_rep=’NULL’,index=False/True,header=Fales/True,cols=[…]])

json
json.loads(jsonobj)
json.dumps(”)

pandas读文本数据时,现将数据完全读进内存后,在确定合适的dtype
pandas.read_csv(file, dtype={columnname:dtype} 来明确指定某列的类型

赞(0) 打赏
未经允许不得转载:技术文档分享 » python文件读写

评论 抢沙发