zoukankan      html  css  js  c++  java
  • pandas的to_csv函数

    分隔符 sep : Field delimiter for the output file (default ”,”)

    dt.to_csv('C:/Users/think/Desktop/Result.csv',sep='?') #使用?分隔需要保存的数据,如果不写,默认是, 

    替换空值 na_rep: A string representation of a missing value (default ‘’)

    dt.to_csv('C:/Users/think/Desktop/Result1.csv',na_rep='NA') #确实值保存为NA,如果不写,默认是空  

    格式 float_format: Format string for floating point numbers

    dt.to_csv('C:/Users/think/Desktop/Result1.csv',float_format='%.2f') #保留两位小数  

    是否保留某列数据 cols: Columns to write (default None)

    dt.to_csv('C:/Users/think/Desktop/Result.csv',columns=['name']) #保存索引列和name列  

    是否保留列名 header: Whether to write out the column names (default True)

    dt.to_csv('C:/Users/think/Desktop/Result.csv',header=0) #不保存列名  

    是否保留行索引 index:  whether to write row (index) names (default True)

    dt.to_csv('C:/Users/think/Desktop/Result1.csv',index=0) #不保存行索引  
  • 相关阅读:
    python爬取酷狗音乐
    python爬取酷我音乐
    排列组合+逆元模板
    python爬取QQVIP音乐
    一维数组的动态和
    买卖股票的最佳时机 II
    最佳买卖股票时机含冷冻期
    买卖股票的最佳时机
    子集
    最短无序连续子数组
  • 原文地址:https://www.cnblogs.com/wzdLY/p/9760970.html
Copyright © 2011-2022 走看看