dateframe取某列数据_获取DataFrame第一列的值(无魔法数字)

  • Post author:
  • Post category:其他


#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



版权声明:本文为weixin_39602280原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。