have the following advantages:
Faster (once set)
Self-explanation (by checking the code, you will know what it has done)
Easy to generate reports or emails
More flexible, because you can define custom Aggregate functions
Read in the data
First, let's build the required environment.
If you want to continue with me, you can download this Excel file.
Import pandas as pd
Import numpy as np
Vers
official documentsOnce you have completed your first kernel, you can return to the document and read the rest. Here is my suggested reading order:
Processing of lost data
Group: Split-apply-combine Mode
Reshaping and data cross-table
Data merging and linking
Input/Output tool (Text,csv,hdf5 ..
col_namesIf C.endswith ("(g)"):Gram_columns.append (c)GRAM_DF = food_info[gram_columns] The column name at the end of the #把以 "G" is indexed to the Dataframe object, resulting in the corresponding multi-column data.Print (Gram_df.head (3))7) data types in Pandas#object-for String values#int-for integer values#float-for Float values#datetime-for Time values#bool-for Boolean values#print (Food_info.dtypes)3,
1 concat
The Concat function is a method underneath the pandas that allows for a simple fusion of data based on different axes.
Pd.concat (Objs, axis=0, join= ' outer ', Join_axes=none, Ignore_index=false, Keys=none, Levels=none, Names=None,
Verify_integrity=false)1 2 1 2 1 2
Parameter descriptionObjs:series,dataframe or a sequence of panel compositions lsitAxis: Axis that needs to merge links, 0
']df_obj[' user number '].isin (alist) #将要过滤的数据放入字典中, uses Isin to filter the data, returns the row index and the results of each row filter, and returns if the match is turedf_obj[df_obj[' user number '].isin (alist)] #获取匹配结果为ture的行Filter data using Dataframe blur (like in sql):df_obj[df_obj[' package '].str.contains (R '. * Voice cdma.* ')] #使用正则表达式进行模糊匹配, * match 0 or unlimited, match 0 or 1 timesData c
How to quickly get started using Python for financial data analysisIntroduction:This series of posts "quantitative small classroom", through practical cases to teach beginners to use Python, pandas for financial data processing, hope to be helpful to the big home." must -read article": "10 400 times-fold strategy sharing-video-line-guided code""All series article
This article mainly introduced the Python pandas in the Dataframe type data operation function method, has certain reference value, now shares to everybody, has the need friend to refer to
The Python data analysis tool pandas Dataframe and series as the primary data structu
connection key in the right Dataframe
Left_index: Use the row index in the left dataframe as the connection key
Right_index: Use the row index in the right dataframe as the connection key
Sort: The default is true to sort the merged data. setting to False in most cases can improve performance
Suffixes: A tuple of string values that specifies the suffix name appended to the column name when the left and right dataframe exist with the s
Pandas is a very important data processing library in Python, and pandas provides a very rich data processing function, which is helpful to machine learning and data preprocessing before data mining.
The following is the recent
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.