In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how Python deletes the content in csv". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "how to delete the content of csv in Python" can help you solve the problem.
Description
1. Use the drop function to delete rows or columns of data in the file.
Example
2. You can delete certain lines, delete rows (a range), and save the data back to the csv file.
Suppose the name of the column we want to delete is' audience ID',' score':
Df=df.drop (['audience ID',' score'], axis=1)
The specified column can be deleted
Delete a few lines
Df.drop ([1mem2]) # Delete the entire row of data of 2 rows of 1meme
Delete a row (a range)
# Delete a line (range) df.drop (df.index [3:6], inplace=True)
Re-save the data to the csv file
# if you want to save a new csv file, what does index=False,encoding= ("data_new.csv", index=False,encoding= "utf-8") python mean? Python is a cross-platform, interpretive, compiled, interactive and object-oriented scripting language that was originally designed to write automated scripts. as versions are constantly updated and new features are added, Python is often used to develop independent and large projects.
This is the end of the introduction to "how Python deletes the content in csv". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.