CH06 -Pandas 【综合练习】

  • 时间紧张,先搞这么多吧,后便继续
import numpy as np
import pandas as pd
df = pd.read_csv('C:/Users/admin/Desktop/joyful-pandas-master/数据集/2002年-2018年上海机动车拍照拍卖.csv')
df.head()
DateTotal number of license issuedlowest priceavg priceTotal number of applicants
02-Jan140013600147353718
12-Feb180013100140574590
22-Mar200014300146625190
32-Apr230016000163344806
42-May235017800183574665
s = pd.Series(df['Total number of license issued']/df['Total number of applicants'])
df_assign=df.assign(Quali=s)
df_assign
DateTotal number of license issuedlowest priceavg priceTotal number of applicantsQuali
02-Jan1400136001473537180.376547
12-Feb1800131001405745900.392157
22-Mar2000143001466251900.385356
32-Apr2300160001633448060.478568
42-May2350178001835746650.503751
.....................
19818-Aug1040288300883651927550.053965
19918-Sep1271287300874101891420.067209
20018-Oct1072888000880701818610.058990
20118-Nov1176687300873741773550.066342
20218-Dec1285087400875081654420.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
DateTotal number of license issuedlowest priceavg priceTotal number of applicants
02-Jan140013600147353718
12-Feb180013100140574590
22-Mar200014300146625190
32-Apr230016000163344806
42-May235017800183574665
..................
19818-Aug104028830088365192755
19918-Sep127128730087410189142
20018-Oct107288800088070181861
20118-Nov117668730087374177355
20218-Dec128508740087508165442

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 =
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值