Getting Started with DataFrame

Source: Internet
Author: User
Keywords dataframe pandas dataframe pandas dataframe tutorial
pandas is the most famous data statistics package in the Python environment, and DataFrame is translated into a data frame, which is a way of data organization. So you may not be able to know it emotionally. For example, you probably used Excel, and it is also A way to organize and present data is simply a table, and use DataFrame to organize data in pandas. If you don't print DataFrame, you can't see the data. Let's take a look at how DataFrame is used.

The first is the introduction of pandas and numpy, which are two packages that are often used together. Pandas depends on numpy. After the introduction, we can directly use np/pd to represent these two modules.

First create a time index, the so-called index (index) is the id of each row of data, can identify the unique value of each row

The randn function is used to create random numbers, the parameters represent the number of rows and columns, and dates is the index column created in the previous step

We can also use a dictionary to create a data frame

If the data length in the dictionary is different, the longest data shall prevail

You can use dtypes to view the data format of each row

Use head to view the first few lines of data (default is the first 5 lines), but you can specify the first few lines

Use tail to view the last 5 rows of data

View column names with columns

View data values, use values

View descriptive statistics, use describe

Use type to see what data type the output descriptive statistics are-DataFrame data

Use T to transpose data, that is, row and column conversion

Sort the data, using sort, the parameter can specify which column of data to sort.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.