- Learning pandas(Second Edition)
- Michael Heydt
- 201字
- 2021-07-02 20:37:08
Creating a Series using Python lists and dictionaries
A Series can be created from a Python list:

The first column of numbers represents the label in the index of the Series. The second column contains the values. dtype: int64 denotes that the data type of the values in the Series is int64.
By default, pandas will create an index consisting of consecutive integers starting at 0. This makes the series look like an array in many other programming languages. As an example, we can look up the value at label 3:

Data types other than integers can be used. The following creates a series of string values:

To create a series consisting of a sequence of n identical values v, use the Python shorthand for list creation, [v]*n. The following creates five values of 2:

A similar type of shorthand is the following, which uses the Python shorthand to use each character as a list item:

A Series can be directly initialized from a Python dictionary. When using a dictionary, the keys of the dictionary are used as the index labels:

- 精通JavaScript+jQuery:100%動態(tài)網(wǎng)頁設(shè)計密碼
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- Expert Android Programming
- 微信小程序項目開發(fā)實戰(zhàn)
- Learning Hunk
- Keras深度學習實戰(zhàn)
- Visual Basic程序設(shè)計實驗指導(第二版)
- PHP編程基礎(chǔ)與實踐教程
- 實戰(zhàn)Java高并發(fā)程序設(shè)計(第2版)
- Mastering Adobe Captivate 7
- OpenCV Android開發(fā)實戰(zhàn)
- Sitecore Cookbook for Developers
- 例解Python:Python編程快速入門踐行指南
- ASP.NET Core 2 High Performance(Second Edition)
- Thymeleaf 3完全手冊