new_store_11 = pd.concat([store_11,month_df],axis = 1,sort = false)
store_11.index = [3052084, 3052085, 3052086, 3052087, 3052088, 3052089, 3052090,
3052091, 3052092, 3052093,
...3088954, 3088955, 3088956, 3088957, 3088958, 3088959, 3088960,
3088961, 3088962, 3088963]
month_df.index = rangeindex(start=0, stop=36880, step=1)
改進做法是:
month_df.index = store_11.index
然後再進行拼接操作
new_store_11 = pd.concat([store_11,month_df],axis = 1,sort = false)
month_sales_all = pd.merge(month_sales_all,get_month_sales(store_unique[i+1]),how = 'left',on = ['月份']) #how = 'left'以左邊的df為參考
def jia(x,y):
z = x+y
return z
def jian(x,y):
print( x-y )
def cheng(x,y):
print( x*y )
operator =
def fun(o,x,y):
return operator.get(o)(x,y)
fun('+',3,4)
def mon0():
return 0
def mon1():
return 31
def mon2():
return 59
def mon3():
return 90
def mon4():
return 120
def mon5():
return 151
def mon6():
return 181
def mon7():
return 212
def mon8():
return 243
def mon9():
return 273
def mon10():
return 304
def mon11():
return 334
operator =
def mon(o):
return operator.get(o)()
print(mon('6'))
####找出所有每天都被賣出的商品###
fullday_code = date[date['days_many'] == 308]
##檢視每天都被賣出的cscode=30104的商品資訊##——煎餅————
data_30104 = data[data['cscode'] == 30104]
##————進行重取樣必須進行的操作
data_30104['filldate'] = pd.to_datetime(data_30104['filldate'])
am_day = data_30104.groupby(['filldate'])['am'].sum().reset_index()
######將filldate設為index
am_day = am_day.set_index(am_day['filldate'])
am_week = am_day['am'].resample('7d',how = 'sum')
am_mon = am_day['am'].resample('1m').sum()
am_se = am_day['am'].resample('3m').sum()
##——————畫圖,每季度、每月、每週銷售量——————##
#plt.subplot(311)
#am_week.plot(figsize=(12,6),title='weekly_30104_am',legend=none)
#plt.subplot(312)
#am_mon.plot(figsize=(12,6),title = 'monthly_30104_am',legend = none)
#plt.subplot(313)
#am_se.plot(figsize=(12,6),title = 'sessionly_30104_am',legend = none)
pandas學習教程 pandas學習
python-pandas 時間日期的處理:
systemtap embedded C 踩坑筆記
官方文件 systemtap的embedded c中,不能 include 也不能用printf和print。那怎麼列印呢?用stap printf。用法與printf一樣。還可以訪問cript中的全域性變數。官方文件中的示例 global var global var2 100 function ...
Aggregation MongoDB踩坑記錄
對某些篩選條件進行分頁查詢,開始每一頁的有效data都不足pagesize,最後發現,aggregation 的pipeline是有先後順序的。錯誤 agg aggregation.newaggregation aggregation.skip curpage 1 pagesize aggregat...
feign踩坑 通過Feign上傳檔案(踩坑)
引入依賴 org.springframework.cloud spring cloud starter openfeign 服務提供者 restcontroller public inte ce fileuploadservice commonresultuploadfile requestpart...