- Learning pandas(Second Edition)
- Michael Heydt
- 348字
- 2021-07-02 20:37:06
Importing pandas
Every notebook we will use starts by importing pandas and several other useful Python libraries first. It will also set up several options to control how pandas renders output in a Jupyter Notebook. This code consists of the following:

The first statement imports NumPy and refers to items in the library as np.. We won't go into much detail on NumPy in this book, but it is occasionally needed.
The second import makes pandas available to the notebook. We will refer to items in the library with the pd. prefix. The from pandas import Series, DataFrame statement explicitly imports the Series and DataFrame objects into the global namespace. This allows us to refer to Series and DataFrame without the pd. prefix. This is convenient as we will use them so frequently that this saves quite a bit of typing.
The import datetime statement brings in the datetime library, which is commonly used in pandas for time series data. It will be included in the imports for every notebook.
The pd.set_option() function calls set up options that inform the notebook how to display output from pandas. The first tells states to render Series and DataFrame output as text and not HTML. The next two lines specify the maximum number of columns and rows to be output. The final option sets the maximum number of characters of output in each rows.
A sharp eye might notice that this cell has no Out [x]:. Not all cells (or IPython statements) will generate output.
If you desire to use IPython instead of Jupyter Notebook to follow along, you can also execute this code in an IPython shell. For example, you can simply cut and paste the code from the notebook cell. Doing so might look like the following:

The IPython shell is smart enough to know you are inserting multiple lines and will indent appropriately. And notice that there is also no Out [x]: in the IPython shell. pd.set_option does not return any content and hence there is no annotation.
- Dynamics 365 Application Development
- Learning Chef
- C語言程序設計基礎與實驗指導
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- 趣學Python算法100例
- Learning Informatica PowerCenter 10.x(Second Edition)
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- 圖數據庫實戰
- MySQL入門很輕松(微課超值版)
- Laravel Application Development Blueprints
- 遠方:兩位持續創業者的點滴思考
- 嵌入式Linux C語言程序設計基礎教程
- 黑莓(BlackBerry)開發從入門到精通
- 零基礎學Java第2版
- 快樂編程:青少年思維訓練