程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python chapter 06 data loading, storage and file format

編輯:Python

Accessing data is the first step in using the tools described in this book . I will highlight pandas Data input and output , Although there are many tools for this purpose in other libraries .

Input and output can be divided into several categories : Read text files and other more efficient disk storage formats , Load the data in the database , utilize Web API Operate network resources .

6.1 Read and write data in text format

pandas Provides some methods for reading tabular data as DataFrame Object function . surface 6-1 They are summarized , among read_csv and read_table It may be the one you will use most in the future .

I'll give you an overview of how these functions convert text data to DataFrame Some of the techniques used in . The options of these functions can be divided into the following categories :

  • Indexes : Treat one or more columns as returned DataFrame Handle , And whether from the file 、 User get column name .
  • Type inference and data conversion : Including conversion of user-defined values 、 And custom missing value tag list .
  • Date resolution : Including combined functions , For example, combine the date and time information scattered in multiple columns into a single column in the result .
  • iteration : Supports block by block iteration of large files .
  • Irregular data problem : Skip some lines 、 The footer 、 Notes or other unimportant things ( For example, numerical data separated by thousands of commas ).

Because the actual data encountered in the work may be very confusing , Some data loading functions ( In especial read_csv) The options for are becoming increasingly complex . Facing different parameters , It's normal to feel headache (read_csv There are more than 50 Parameters ).pandas The documentation has examples of these parameters , If you find it difficult to read a document , You can use enough similar examples


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved