使用pandas快速进行文件操作

需求:原本的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 pandasdf = 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')

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章