Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to read and save multi-format data files with Pandas

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to read and save multi-format data files in Pandas. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Code snippet:

# Pandas file reads and saves data to multiple format files # In [23]: import pandas as pd# In [24]: df = pd.read_csv ('data_price.csv') df.head () # set the index column to be saved as a new csv format file # In [25]: df.set_index (' Date') Inplace=True) df.to_csv ('data_pricenew.csv') # read the new csv file # In [26]: df = pd.read_csv (' data_pricenew.csv') df.head () # set the first column index column # In [27]: df = pd.read_csv ('data_pricenew.csv' Index_col=0) df.head () # rename column # In [28]: df.columns= ['NewPrices'] df.head () # Save as csv file Does not include column name # In [29]: df.to_csv ('data_pricenew2.csv',header=False) # In [30]: df = pd.read_csv (' data_pricenew2.csv',\ names= ['Date','Prices']) Index_col=0) df.head () # Save as html format file # In [31]: df.to_html ('dataprice.html') # for the file reading and saving format of pandas, see the official website address: # https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html

On "Pandas how to achieve multi-format data file reading and saving" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report