import numpy as np
import pandas as pd
df = pd.read_csv('C:/Users/admin/Desktop/joyful-pandas-master/数据集/2002年-2018年上海机动车拍照拍卖.csv')
df.head()
| Date | Total number of license issued | lowest price | avg price | Total number of applicants |
---|
0 | 2-Jan | 1400 | 13600 | 14735 | 3718 |
---|
1 | 2-Feb | 1800 | 13100 | 14057 | 4590 |
---|
2 | 2-Mar | 2000 | 14300 | 14662 | 5190 |
---|
3 | 2-Apr | 2300 | 16000 | 16334 | 4806 |
---|
4 | 2-May | 2350 | 17800 | 18357 | 4665 |
---|
s = pd.Series(df['Total number of license issued']/df['Total number of applicants'])
df_assign=df.assign(Quali=s)
df_assign
| Date | Total number of license issued | lowest price | avg price | Total number of applicants | Quali |
---|
0 | 2-Jan | 1400 | 13600 | 14735 | 3718 | 0.376547 |
---|
1 | 2-Feb | 1800 | 13100 | 14057 | 4590 | 0.392157 |
---|
2 | 2-Mar | 2000 | 14300 | 14662 | 5190 | 0.385356 |
---|
3 | 2-Apr | 2300 | 16000 | 16334 | 4806 | 0.478568 |
---|
4 | 2-May | 2350 | 17800 | 18357 | 4665 | 0.503751 |
---|
... | ... | ... | ... | ... | ... | ... |
---|
198 | 18-Aug | 10402 | 88300 | 88365 | 192755 | 0.053965 |
---|
199 | 18-Sep | 12712 | 87300 | 87410 | 189142 | 0.067209 |
---|
200 | 18-Oct | 10728 | 88000 | 88070 | 181861 | 0.058990 |
---|
201 | 18-Nov | 11766 | 87300 | 87374 | 177355 | 0.066342 |
---|
202 | 18-Dec | 12850 | 87400 | 87508 | 165442 | 0.077671 |
---|
203 rows × 6 columns
df_assign.loc[df_assign['Quali']>0.5].head(1).Date
4 2-May
Name: Date, dtype: object
df_1 = df.copy()
df_1
| Date | Total number of license issued | lowest price | avg price | Total number of applicants |
---|
0 | 2-Jan | 1400 | 13600 | 14735 | 3718 |
---|
1 | 2-Feb | 1800 | 13100 | 14057 | 4590 |
---|
2 | 2-Mar | 2000 | 14300 | 14662 | 5190 |
---|
3 | 2-Apr | 2300 | 16000 | 16334 | 4806 |
---|
4 | 2-May | 2350 | 17800 | 18357 | 4665 |
---|
... | ... | ... | ... | ... | ... |
---|
198 | 18-Aug | 10402 | 88300 | 88365 | 192755 |
---|
199 | 18-Sep | 12712 | 87300 | 87410 | 189142 |
---|
200 | 18-Oct | 10728 | 88000 | 88070 | 181861 |
---|
201 | 18-Nov | 11766 | 87300 | 87374 | 177355 |
---|
202 | 18-Dec | 12850 | 87400 | 87508 | 165442 |
---|
203 rows × 5 columns
df_1['Year'] = df_1['Date'].apply(lambda x : 2000+int(x.split('-')[0]))
df_1['Month'] = df_1['Date'].apply(lambda x : x.split('-')[1])
col_name=df_1.columns.tolist()
col_name
['Date',
'Total number of license issued',
'lowest price ',
'avg price',
'Total number of applicants',
'Year',
'Month']
df_1 =