#encoding:utf-8
import pandas as pd
import matplotlib.pyplot as plt
#最美的时候遇见你 少年班 既然青春留不住
cols=’name add remove gongsi daoyan yanyuan type boxoffice area’.split()
data=pd.read_csv(‘../data/film_log3.csv’,names=cols,sep=’;’)
data[‘add’]=pd.to_datetime(data[‘add’])
data[‘remove’]=pd.to_datetime(data[‘remove’])
def get_data(_df):
try:
_box=_df[‘boxoffice’][15:]
_df[‘boxoffice’]=float(_box)
except:
pass
try:
_day=(_df[‘remove’]-_df[‘add’]).days
_df[‘day’]=_day
if _day%7==0:
_df[‘week’]=_day/7
else:
_df[‘week’]=_day//7+1
except:
pass
return _df
data=data.apply(get_data,ax