# Pandas common operations

Source: Internet
Author: User
Tags install pandas

Reference Tianchi AI
GitHub Blog Portal
CSDN Blog Portal

Installing Pandas
Pip install Pandas from the command prompt
or through the third-party release version Anaconda for mouse operation installation

NumPy Learning Tutorial Portal

82791862

Creation of Series
``import numpy as np, pandas as pd# 通过一维数组创建序列arr1 = np.arange(10)  # 创建一个0~9的numpy数组对象print(arr1)           # 打印这个数组print(type(arr1)) 　　#打印这个数组的类型s1 = pd.Series(arr1)　# 将数组转换为 Seriesprint(s1)             # 打印出这个Seriesprint(type(s1))       # 打印出这个Series的数据类型类型``

Create a sequence by way of a dictionary

``dic1 = {‘a‘: 10, ‘b‘: 20, ‘c‘: 30, ‘d‘: 40, ‘e‘: 50}  # 创建一个字典dic1print(dic1)           # 打印这个字典print(type(dic1))     # 打印这个字典的数据类型s2 = pd.Series(dic1)  # 将这个字典转换为Seriesprint(s2)             # 打印转换后的Seriesprint(type(s2))       ``
Creation of Dataframe

There are three main ways to create a data frame
1. Create a data frame from a two-dimensional array

``arr2 = np.array(np.arange(12)).reshape(4, 3)  # 创建一个0~11的数组,然后reshape成4*3的矩阵print(arr2)               # 打印出这个矩阵print(type(arr2))         # 打印出这个矩阵的数据类型df1 = pd.DataFrame(arr2)  # 将这个矩阵转换为 DataFrameprint(df1)                # 打印出转换后的DataFrameprint(type(df1))          # 打印出这个DataFrame的数据类型``

2. Create a data frame by using a dictionary
(1) List of dictionaries

``dic2 = {‘a‘: [1, 2, 3, 4], ‘b‘: [5, 6, 7, 8], ‘c‘: [9, 10, 11, 12], ‘d‘: [13, 14, 15, 16]}  # 创建一个字典print(dic2)        # 打印出这个字典的内容print(type(dic2))  # 打印出这个字典的数据类型df2 = pd.DataFrame(dic2)  # 将这个字典转换为DataFrameprint(df2)                # 打印出转化后的DataFrameprint(type(df2))          # 打印出这个DataFrame的数据类型``

(2) Nested dictionaries

``dic3 = {‘one‘: {‘a‘: 1, ‘b‘: 2, ‘c‘: 3, ‘d‘: 4}, ‘two‘: {‘a‘: 5, ‘b‘: 6, ‘c‘: 7, ‘d‘: 8},        ‘three‘: {‘a‘: 9, ‘b‘: 10, ‘c‘: 11, ‘d‘: 12}}  # 创建了一个嵌套的字典print(dic3)        # 打印出这个嵌套的字典print(type(dic3))  # 打印出这个字典的数据类型df3 = pd.DataFrame(dic3)  # 将这个嵌套字典转换为DataFrameprint(df3)                # 打印出转换后的DataFrameprint(type(df3))          # 打印出这个DataFrame的数据类型``

3. Create a data frame with a data frame

``df4 = df3[[‘one‘, ‘three‘]]  # 通过调用df3中的两列数据进行创建DataFrameprint(df4)                   # 打印出这个调用df3中数据的DataFrameprint(type(df4))             # 打印出这个DataFrame的数据类型s3 = df3[‘one‘]  # 通过调用df3中的一列数据进行创建DataFrame会创建出Seriesprint(s3)        # 打印出这个Seriesprint(type(s3))  # 打印出这个Series的数据类型``
Get data by index value or index label
``import numpy as np, pandas as pds4 = pd.Series(np.array([1, 1, 2, 3, 5, 8]))  # 创建一个Series数据print(s4)        # 打印出这个数据print(s4.index)  # 打印出这个数据的索引``

Now let's set a custom index value for the sequence:

``s4.index = [‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘]  # 手动修改s4这个数据的索引(index)print(s4)                             # 打印修改索引后的Seriesprint(‘s4:\n‘, s4)              # 取出下标为 3 的数据print(‘s4[e]:\n‘, s4[‘e‘])            # 取出索引为 e 的数据print(‘s4[1,3,5]:\n‘, s4[[1, 3, 5]])  # 取出下标为 1 3 5 的数据print("s4[[‘a‘,‘b‘,‘d‘,‘f‘]]:\n", s4[[‘a‘, ‘b‘, ‘d‘, ‘f‘]])  # 取出索引为 a b d f 的数据print(‘s4[:4]:\n‘, s4[:4])            # 切片到下标为 4 的所有数据print("s4[‘c‘:]:\n", s4[‘c‘:])        # 切片索引为 c 开始后面所有的数据print("s4[‘b‘:‘e‘]:\n", s4[‘b‘:‘e‘])  # 切片索引为 b 开始 e 结束(左闭右开)的所有数据``

Automation alignment
If you have two sequences, you need to perform arithmetic operations on the two sequences, and the existence of the index reflects its value-automation alignment.

``s5 = pd.Series(np.array([10, 15, 20, 30, 55, 80]), index=[‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘])  # 创建一个Series并指定索引print(s5)       # 打印出这个Seriess6 = pd.Series(np.array([12, 11, 13, 15, 14, 16]), index=[‘a‘, ‘c‘, ‘g‘, ‘b‘, ‘d‘, ‘f‘])  # 创建一个Series并指定索引print(s6)       # 打印出这个Seriesprint(s5 + s6)  # 将两个Series进行相加操作print(s5 / s6)  # 将两个Series进行相除操作# 由于s5中没有对应的g索引，s6中没有对应的e索引，所以数据的运算会产生两个缺失值NaN。# 注意，这里的算术结果就实现了两个序列索引的自动对齐，而非简单的将两个序列加总或相除对于数据框的对齐，不仅仅是行索引的自动对齐，同时也会自动对齐列索引（变量名）``
Querying data with Pandas
``import pandas as pd# 可以通过布尔索引有针对的选取原数据的子集、指定行、指定列等。stu_dic = {‘Age‘: [14, 13, 13, 14, 14, 12, 12, 15, 13, 12, 11, 14, 12, 15, 16, 12, 15, 11, 15],           ‘Height‘: [69, 56.5, 65.3, 62.8, 63.5, 57.3, 59.8, 62.5, 62.5, 59, 51.3, 64.3, 56.3, 66.5, 72, 64.8, 67, 57.5, 66.5],           ‘Name‘: [‘Alfred‘, ‘Alice‘, ‘Barbara‘, ‘Carol‘, ‘Henry‘, ‘James‘, ‘Jane‘, ‘Janet‘, ‘Jeffrey‘, ‘John‘,  ‘Joyce‘, ‘Judy‘, ‘Louise‘, ‘Marry‘, ‘Philip‘, ‘Robert‘, ‘Ronald‘, ‘Thomas‘, ‘Willam‘],           ‘Sex‘: [‘M‘, ‘F‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘F‘, ‘F‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘M‘, ‘M‘, ‘M‘],           ‘Weight‘: [112.5, 84, 98, 102.5, 102.5, 83, 84.5, 112.5, 84, 99.5, 50.5, 90, 77, 112, 150, 128, 133, 85, 112]}# 创建了一个DataFrame数据框student = pd.DataFrame(stu_dic)``

Query data for the first 5 rows or the end of 5 lines Student.head () Student.tail ()

``print(student)                      # 打印这个数据框print(‘前五行:\n‘, student.head())  # 查询这个数据框的前五行print(‘后五行:\n‘, student.tail())  # 查询这个数据框的后五行``

Querying the specified row

``print(student.loc[[0, 2, 4, 5, 7]])  # 这里的loc索引标签函数必须是中括号[]``

Querying the specified column

``print(student[[‘Name‘, ‘Height‘, ‘Weight‘]].head())  # 如果多个列的话，必须使用双重中括号``

The specified column can also be queried by the LOC index label

``print(student.loc[:, [‘Name‘, ‘Height‘, ‘Weight‘]].head)``

Find out all information about girls over 12 years of age

``print(student[(student[‘Sex‘] == ‘F‘) & (student[‘Age‘] > 12)])``

Find out the names, height and weight of all girls over the age of 12

``print(student[(student[‘Sex‘] == ‘F‘) & (student[‘Age‘] > 12)][[‘Name‘, ‘Height‘, ‘Weight‘]])``
Statistical analysis using the dataframes of Pandas
` ` import NumPy as NP, pandas as Pdnp.random.seed (1234) D1 = PD. Series (2 * np.random.normal (SIZE=100) + 3) D2 = NP.RANDOM.F (2, 4, size=100) D3 = Np.random.randint (1, +, size=100) print (' Non- Empty element calculation: ', D1.count ()) # Non-empty element calculates print (' min: ', D1.min ()) # Minimum print (' Max: ', D1.max ()) # max value Print (' Minimum position: ', D1.idxmin ()) # The position of the minimum value, similar to the Which.min function in R, print (' Maximum position: ', D1.idxmax ()) # Position of the maximum value, similar to the Which.max function in R              Print (' 10% min: ', D1.quantile (0.1)) # 10% min. print (' Sum: ', D1.sum ()) # sum print (' mean: ', D1.mean ())               # mean Print (' median: ', D1.median ()) # median print (' majority: ', D1.mode ()) # Majority print (' Variance: ', D1.var ())             # Variance Print (' Standard deviation: ', D1.STD ()) # Standard deviation print (' mean absolute deviation: ', D1.mad ()) # Average Absolute deviation of print (' skewness: ', D1.skew ()) # skewness Print (' kurtosis: ', D1.kurt () #) # kurtosis print (' Descriptive statistic: ', D1.describe ()) # Output multiple descriptive statistical indicators at once # It must be noted that the DESCIRB The E method can only be used for sequences or data frames, and a one-dimensional array is a `  without this method.`

Here you customize a function that summarizes all of these statistical description metrics together:

``def stats(x):    return pd.Series([x.count(), x.min(), x.idxmin(), x.quantile(.25), x.median(), x.quantile(.75),x.mean(), x.max(), x.idxmax(), x.mad(), x.var(), x.std(), x.skew(), x.kurt()],index=[‘Count‘, ‘Min‘, ‘Whicn_Min‘, ‘Q1‘, ‘Median‘, ‘Q3‘, ‘Mean‘, ‘Max‘,‘Which_Max‘, ‘Mad‘, ‘Var‘, ‘Std‘, ‘Skew‘, ‘Kurt‘])print(stats(d1))  # 打印统计后的指标``

Apply this function to each column

``df = pd.DataFrame(np.array([d1,d2,d3]).T,columns=[‘x1‘,‘x2‘,‘x3‘])print(df.head())print(df.apply(stats))``

The solution of correlation coefficients (corr) and covariance matrices (cov) of continuous variables

``print(df.corr())``

The calculation of correlation coefficients can call the Pearson method or the Kendell method or the Spearman method, using the Pearson method by default.

``print(df.corr(‘spearman‘))``

If you are concerned with the correlation coefficients of a variable and the rest of the variables, you can use Corrwith, which only concerns the correlation coefficients of X1 and the remaining variables.

``print(df.corrwith(df[‘x1‘]))``

Covariance matrix between numerical variables

``print(df.cov())``
Implementing SQL Operations with Pandas
``import pandas as pd, numpy as np# 原数据stu_dic = {‘Age‘: [14, 13, 13, 14, 14, 12, 12, 15, 13, 12, 11, 14, 12, 15, 16, 12, 15, 11, 15],           ‘Height‘: [69, 56.5, 65.3, 62.8, 63.5, 57.3, 59.8, 62.5, 62.5, 59, 51.3, 64.3, 56.3, 66.5, 72, 64.8, 67, 57.5, 66.5],           ‘Name‘: [‘Alfred‘, ‘Alice‘, ‘Barbara‘, ‘Carol‘, ‘Henry‘, ‘James‘, ‘Jane‘, ‘Janet‘, ‘Jeffrey‘, ‘John‘, ‘Joyce‘, ‘Judy‘, ‘Louise‘, ‘Marry‘, ‘Philip‘, ‘Robert‘, ‘Ronald‘, ‘Thomas‘, ‘Willam‘],           ‘Sex‘: [‘M‘, ‘F‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘F‘, ‘F‘, ‘F‘, ‘F‘, ‘M‘, ‘M‘, ‘M‘, ‘M‘, ‘M‘],           ‘Weight‘: [112.5, 84, 98, 102.5, 102.5, 83, 84.5, 112.5, 84, 99.5, 50.5, 90, 77, 112, 150, 128, 133, 85, 112]}student = pd.DataFrame(stu_dic)  # 将数据转换为DataFrameprint(student)                   # 打印出这个数据``
Increase

``dic = {‘Name‘: [‘LiuShunxiang‘, ‘Zhangshan‘], ‘Sex‘: [‘M‘, ‘F‘], ‘Age‘: [27, 23], ‘Height‘: [165.7, 167.2],‘Weight‘: [61, 63]}  # 需要增加的数据student2 = pd.DataFrame(dic)  # 增加数据print(student2)               # 打印出增加数据后的DataFrame``

Adding data from Student2 to student can now be achieved through the CONCAT function

``student3 = pd.concat([student, student2])print(student3)``

Are you aware of that? In the database, the Union must require the column order of the two tables to be consistent, and here the Concat function automatically aligns the two data frame variables!

Adding columns is actually easier in pandas, such as adding a list of student scores in Student2

``print(pd.DataFrame(student2, columns=[‘Age‘, ‘Weight‘, ‘Name‘, ‘Sex‘, ‘Weight‘, ‘Score‘]))``
By deleting

The delete data frame Student2 is implemented with the DEL command, which removes all Python objects

``del student2  # 删除数据框 student2, 通过del命令可以删除Python的所有对象print(student2)``

Deletes the specified row

``print(student.drop([0, 1, 3, 6]))``

Delete all students under the age of 14

``print(student[‘Age‘] > 14)``

Delete the specified column

``print(student.drop([‘Height‘, ‘Weight‘], axis=1).head())  # axis默认为0选择行``
Change

Methods for modifying the combined Boolean index and assignment of original records

``student3.loc[student3[‘Name‘] == ‘LiuShunxiang‘, ‘Height‘] = 173print(student3[student3[‘Name‘] == ‘LiuShunxiang‘][[‘Name‘, ‘Height‘]])``
Check

aggregation, sorting, and multi-table join operations
Aggregation: Aggregation of data can be achieved through the GroupBy () function in the Pandas module

``print(student.groupby(‘Sex‘).mean())``

If the original data is not restricted, the aggregate function automatically selects the numeric data for the aggregation calculation. If you do not want to calculate the average age, you need to reject the change amount

``print(student.drop(‘Age‘, axis=1).groupby(‘Sex‘).mean())``

GroupBy can also use multiple grouping variables, such as basic age and gender groupings, to calculate the average of height and weight

``print(student.groupby([‘Sex‘, ‘Age‘]).mean())``

Calculate multiple statistics for each grouping

``print(student.drop(‘Age‘, axis=1).groupby(‘Sex‘).agg([np.mean, np.median]))``
Sort

Sequencing of sequences and data frames using Sort_index and sort_values

``Data = pd.Series(np.array(np.random.randint(1, 20, 10)))print(Data)print(Data.sort_index())print(Data.sort_values(ascending=False))``

The data frame is generally sorted by value

``print(student.sort_values(by=[‘Age‘, ‘Height‘]))``
Multi-table Connection

The connection between multiple tables is also a very common database operation, connecting the inner and outer connections,
Implemented by the JOIN keyword in the database language, pandas I recommend using the merger function to implement various connection operations of the data.
The following is a list of students ' scores:

``dic2 = {‘Name‘: [‘Alfred‘, ‘Alice‘, ‘Barbara‘, ‘Carol‘, ‘Henry‘, ‘Jeffrey‘, ‘Judy‘, ‘Philip‘, ‘Robert‘, ‘Willam‘], ‘Score‘: [88, 76, 89, 67, 79, 90, 92, 86, 73, 77]}score = pd.DataFrame(dic2)print(score)``

Now I want to make a connection between student table student and Student score table score

``stu_score1 = pd.merge(student, score, on=‘Name‘)print(stu_score1)``

Note that by default, the merge function implements an inner join between two tables, that is, the data that returns the common part of the two tables.

You can use the how parameter to set the way to connect, left for left join, right to connect, and outer for outer connection.

``stu_score2 = pd.merge(student, score, on=‘Name‘, how=‘left‘)print(stu_score2)``
Processing of missing values using pandas three-way method to remove the method to fill the interpolation method: When the data of a variable most of the values are missing values, you can consider deleting the change amount, when the missing values are randomly distributed, and the missing number is not many, you can also delete these missing observations. Substitution method: For continuous type variables, if the distribution of variables is approximate or normal distribution, you can use the mean to replace those missing values, if the variables are biased, you can use the median to replace those missing values, for discrete variables, we generally use the majority to replace those with missing observations. Interpolation method: Interpolation method is based on Monte Carlo simulation method, combined with linear model, generalized linear model, decision tree and other methods to calculate the predicted values to replace the missing values.
``import pandas as pd, numpy as npstu_score = {‘Score‘: [88.0, 76.0, 89.0, 67.0, 79.0, None, None, None, 90.0, None, None, 92.0, None, None, 86.0, 73.0, None, None, 77.0]}stu_score2 = pd.DataFrame(stu_score)s = stu_score2[‘Score‘]print(s)# 结合sum函数和isnull函数来检测数据中含有多少缺失值print(‘缺失值个数:‘, sum(pd.isnull(s)))``

Delete missing values directly

``print(‘s.dropna():\n‘, s.dropna())``

By default, Dropna will delete anything that contains a missing merit line, and we'll construct a database to try

``df = pd.DataFrame([[1, 1, 2], [3, 5, np.nan], [13, 21, 34], [55, np.nan, 10], [np.nan, np.nan, np.nan], [np.nan, 1, 2]], columns=(‘x1‘, ‘x2‘, ‘x3‘))print(‘df:\n‘, df)print(‘df.dropna():\n‘, df.dropna())``

Using a constant to fill missing values, you can use the Fillna function to achieve a simple fill job

``print(‘df.fillna(0):\n‘, df.fillna(0))  # 用 0 填补所有缺失值``

Fill with the preceding or latter fill

``print(‘method="ffill":\n‘, df.fillna(method=‘ffill‘))print(‘method="bfill":\n‘, df.fillna(method=‘bfill‘))``

Use constants to populate different columns

``print("{‘x1‘: 1, ‘x2‘: 2, ‘x3‘: 3}:\n", df.fillna({‘x1‘: 1, ‘x2‘: 2, ‘x3‘: 3}))x1_median = df[‘x1‘].median()x2_mean = df[‘x2‘].mean()x3_mean = df[‘x3‘].mean()print(x1_median)print(x2_mean)print(x3_mean)print(df.fillna({‘x1‘: x1_median, ‘x2‘: x2_mean, ‘x3‘: x3_mean}))``

When using the Fill method, it is more reasonable to use the majority, mean, or median padding of each column relative to the constant fill or the preceding and latter fills, which is also a quick way to work.

Using pandas to implement Excel pivot table functionality
``Import pandas as PD, NumPy as np# pivot_table (data, Values=none, Index=none, Columns=none, aggfunc= ' mean ', fill_value=none , Margins=false, Dropna=true, margins_name= ' all ') # Data: Datasheet required for PivotTable Action # Values: Specify fields to be aggregated # index: Specify some primitive variables as row index # Columns: Specifies which discrete grouping variable # Aggfunc: Specifies the appropriate aggregate function # Fill_value: Replaces missing values with a constant, does not replace the # margins by default: whether to summarize rows or columns, default does not summarize # Dropna: Default all observations are missing columns # Margins_name: The name of the default row rollup or column rollup is ' all ' Stu_dic = {' Age ': [14, 13, 13, 14, 14, 12, 12, 15, 13, 12, 11, 14, 12, 15, 16, 12, 15, 11 , [+], ' Height ': [69, 56.5, 65.3, 62.8, 63.5, 57.3, 59.8, 62.5, 62.5, 59, 51.3, 64.3, 56.3, 66.5, 72, 64.8, 67, 57.5, 66.5], ' Name ': [' Alfred ', ' Alice ', ' Barbara ', ' Carol ', ' Henry ', ' James ', ' Jane ', ' Janet ', ' Jeffrey ', ' John  ', ' Joyce ', ' Judy ', ' Louise ', ' Marry ', ' Philip ', ' Robert ', ' Ronald ', ' Thomas ', ' Willam '], ' Sex ': [' M ', ' f ', ' F ', ' F ', ' m ', ' m ', ' f ', ' f ', ' m ', ' m ', ' f ', ' F ', ' F ', ' f ', ' m ', ' m ', ' m ', ' m ', ' m ', ' Weight ': [112.5, 84, 98, 102. 5, 102.5, 83, 84.5, 112.5, 84, 99.5, 50.5, 133, 112]}student = PD, and Max, A. DataFrame (Stu_dic)``

A statistical summary of a grouping variable (SEX), a numeric variable (Height)

``Table1 = pd.pivot_table(student, values=[‘Height‘], columns=[‘Sex‘])print(Table1)``

Statistical summary of a grouping variable (SEX), two numeric variables (height,weight)

``Table2 = pd.pivot_table(student, values=[‘Height‘, ‘Weight‘], columns=[‘Sex‘])print(Table2)``

Statistical summary of two grouping variables (SEX, age), two numeric variables (Height, Weight)

``Table3 = pd.pivot_table(student, values=[‘Height‘, ‘Weight‘], columns=[‘Sex‘, ‘Age‘])print(Table3)``

It is clear that such a result is not as expected in Excel, how does it become a form of a list? It's simple to do a non-stacking operation (unstack) of the results

``Table4 = pd.pivot_table(student, values=[‘Height‘, ‘Weight‘], columns=[‘Sex‘, ‘Age‘]).unstack()print(Table4)``

Using multiple aggregate functions

``Table5 = pd.pivot_table(student, values=[‘Height‘, ‘Weight‘], columns=[‘Sex‘], aggfunc=[np.mean, np.median, np.std])print(Table5)``

For more pivot table operations, refer to the http://python.jobbole.com/81212/

Use of Multilayer indexes

Hierarchical index of a series, which is a two-dimensional array, equivalent to two indexes that determine a value
Row and column indexes that are somewhat similar to Dataframe

``import pandas as pd, numpy as nps = pd.Series(np.arange(1, 10), index=[[‘a‘, ‘a‘, ‘a‘, ‘b‘, ‘b‘, ‘c‘, ‘c‘, ‘d‘, ‘d‘], [1, 2, 3, 1, 2, 3, 1, 2, 3]])print(‘s:\n‘, s)print(‘s.index:\n‘, s.index)# 选取外层索引为 a 的数据print("s[‘a‘]:\n", s[‘a‘])# 选取外层索引为 a 和内层索引为 1 的数据print("s[‘a‘, 1]:\n", s[‘a‘, 1])# 选取外层索引为 a 和内层索引为 1,3的数据print("s[‘a‘][[1, 3]]:\n", s[‘a‘][[1, 3]])# 层次化索引的切片,包括右端的索引print(‘s[["a", "c"]]:\n‘, s[[‘a‘, ‘c‘]])print(‘s["b":"d"]:\n‘, s[‘b‘:‘d‘])# 通过unstack方法可以将Series变成一个DataFrame# 数据的类型以及数据的输出结构都变成了DataFrame,对于不存在的位置使用NaN填充print(‘s.unstack():\n‘, s.unstack())``

Hierarchical index of Dataframe

``data = pd.DataFrame(np.random.randint(0, 150, size=(8,12)),columns=pd.MultiIndex.from_product([[‘模拟考‘, ‘正式考‘],[‘数学‘, ‘语文‘, ‘英语‘, ‘物理‘, ‘化学‘, ‘生物‘]]),index=pd.MultiIndex.from_product([[‘期中‘, ‘期末‘],[‘雷军‘, ‘李斌‘],[‘测试一‘, ‘测试二‘]]))print(‘data:\n‘, data)print(‘data["模拟考"]["语文","数学"]:\n‘, data[‘模拟考‘][[‘语文‘, ‘数学‘]])print("data.loc[‘期中‘, ‘雷军‘, ‘测试一‘][‘模拟考‘, ‘数学‘]:\n", data.loc[‘期中‘, ‘雷军‘, ‘测试一‘][‘模拟考‘, ‘数学‘])print("data.loc[‘期中‘, ‘雷军‘, ‘测试一‘]:\n", data.loc[‘期中‘, ‘雷军‘, ‘测试一‘])print("data[‘正式考‘]:\n", data[‘正式考‘])``

Pandas common operations

Related Keywords:

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.