Day1—#100 Days of coding

  1. print()

1:第一个function_ print()

2:""与‘’ string and code

3:换行的backslash

print("Hello World!\nHello World!")

4:学习string的概念 

String Concatenation

5:Indentation

6:Syntax error

7:code block 就是感觉是一行代码

8:input() function
A promt for the user

9:Python Variables

10.len()计算字符 working with string but end up as a integer

11:Data Types

12:type() 
#to find out which kind of type is
Once you print it , you will know.

13:type conversion/type casting
str(  ) float(  ) 

14:

print(6/3)
float👆2.0

15:

1)+

2)-

3)*

4)/

5)** 次方

12:Subscript__pull out a number(begin from 0)

"Hello"[4]
print("Hello"[4])

13:Integer

123_456_789

14:Float

3141.59

15:Boolean

True \ False

#coding:utf8 import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np sns.set_style('darkgrid') import matplotlib.font_manager as fm myfont=fm.FontProperties(fname=r'./data/simhei.ttf') #请完善下面的函数 def push_week(new_data): ############ Begin ############ new_data=new_data[new_data['type']==4].copy() #选取样本 new_data['weekdays'] = pd.to_datetime(new_data['time']).apply(lambda x: x.weekday()+1) #时间转化 week_days = new_data.groupby('weekdays')['user_id'].count() #统计购买次数 fig=plt.figure(figsize=(8,6)) #设置大小 bar_width = 0.33 # 设置宽度 plt.bar(week_days.index.values , week_days.values, bar_width, label='下单的次数') plt.xlabel('时间',fontproperties=myfont,fontsize=9) plt.ylabel('数量',fontproperties=myfont,fontsize=9) plt.title('一周内每天的下单情况',fontproperties=myfont,fontsize=12) plt.xticks(week_days.index.values, ('周一', '周二', '周三', '周四', '周五', '周六', '周日'),fontproperties=myfont,fontsize=9) plt.ylim(0,300) plt.legend(prop=myfont) ############ End ############ plt.savefig('./task2/task2_week.png') plt.close(fig) def push_date(new_data): new_data = new_data[(new_data['type'] == 4) & (pd.to_datetime(new_data['time']) < pd.to_datetime('2016-03-01'))].copy() #选出2016年数据 new_data['days'] = [x.day for x in pd.to_datetime(new_data['time'])] #选出天数 renew=new_data.groupby('days')['sku_id'].count() fig = plt.figure(figsize=(8, 6)) plt.plot(renew.index.values,renew.values,label='购买次数') plt.xlabel('天数',fontproperties=myfont,fontsize=9) plt.ylabel('次数',fontproperties=myfont,fontsize=9) plt.title('购买量和月内日期的关系',fontproperties=myfont,fontsize=12) plt.legend(prop=myfont) ############ End ############ plt.savefig('./task2/task2_date.png') plt.close(fig) 报错src/task2_test.py:22: FutureWarning: The pandas.datetime class is deprecated and will be removed from pandas in a future version. Import from datetime instead. data['weekdays'] = pd.to_datetime(data['time']).apply(pd.datetime.weekday) + 1 购买意愿与星期之间的关系图完成! 购买意愿与日期之间的关系图完成!
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值