iT邦幫忙

0

使用pandas快速進行文件操作

  • 分享至 

  • xImage
  •  

需求:原本的csv文件的欄目太多了,裁減成所需的欄目;
使用pandas進行操作非常快:這是Chatgpt說的關於pandas和SQL的區別:
In summary, SQL and Pandas have different strengths and use cases. SQL is best suited for working with large, structured datasets stored in a database, while Pandas is best suited for working with smaller datasets stored in memory or in a variety of file formats. Pandas provides a more flexible and intuitive data structure, along with a rich set of functions and methods for data analysis and manipulation.

pandas的特點是用來處理文件類型的數據;
使用drop就能夠刪除不要的列了

import pandas
df = pandas.read_csv("./RFIDRingIDBindingTableSample.txt")
print(df.head(5))
df = df.drop(columns=['Device'])
print(df.head(5))
df.to_csv('./RFIDRingIDBindingTable.txt', header=None, index=None, sep=' ', mode='a')

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言