i have following dataframe:
fak_art fak_dat leist_dat kd_crm mw_bw eq_nr material \ 0 zpaf 2015-05-18 2015-05-31 tmd e 1003507107 g230ets 1 zpaf 2015-05-18 2015-05-31 tmd b 1003507107 g230ets 2 zpaf 2015-05-18 2015-05-31 tmd e 1003507108 g230ets 3 zpaf 2015-05-18 2015-05-31 tmd b 1003507108 g230ets 4 zpaf 2015-05-18 2015-05-31 tmd e 1003507109 g230ets 5 zpaf 2015-05-18 2015-05-31 tmd b 1003507109 g230ets 6 zpaf 2015-05-18 2015-05-31 tmd e 1003507110 g230ets 7 zpaf 2015-05-18 2015-05-31 tmd b 1003507110 g230ets 8 zpaf 2015-05-18 2015-05-31 tmd e 1003507111 g230ets
. . .
387976 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022686 a60ets 387977 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022686 a60ets 387978 zpaf 2016-02-12 2016-02-29 t-home icp e 1001022712 a60ets 387979 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022712 a60ets 387980 zpaf 2016-02-12 2016-02-29 t-home icp e 1001022735 a60ets 387981 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022735 a60ets 387982 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022735 a60ets 387983 zpaf 2016-02-12 2016-02-29 t-home icp e 1001022748 a60ets 387984 zpaf 2016-02-12 2016-02-29 t-home icp b 1001022748 a60ets 387985 zpaf 2016-02-12 2016-02-29 t-home icp e 1001022760 a60ets
now want select rows date 2015-05-31.
i tried little bit around handle date_range errors:
valueerror: length of values not match length of index
or
valueerror: must specify 2 of start, end, or periods
my idea that:
data_faktura['leist_dat'] = pd.date_range('2016-01-31', '2016-01-31')
but error!
how can fix or solve that?
you can set_index
column leist_dat
, select ix
:
#change 2016-02-29 datetime data_fakture = data_fakture.set_index('leist_dat').ix['2016-02-29'] print (data_fakture) fak_art fak_dat kd_crm mw_bw eq_nr material leist_dat 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022760 a60ets
or loc
:
data_fakture = data_fakture.set_index('leist_dat').loc['2016-02-29'] print (data_fakture) fak_art fak_dat kd_crm mw_bw eq_nr material leist_dat 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022760 a60ets
you can select start , end date:
data_fakture = data_fakture.set_index('leist_dat').ix['2015-05-31':'2016-02-29'] print (data_fakture) fak_art fak_dat kd_crm mw_bw eq_nr material leist_dat 2015-05-31 zpaf 2015-05-18 tmd e 1003507107 g230ets 2015-05-31 zpaf 2015-05-18 tmd b 1003507107 g230ets 2015-05-31 zpaf 2015-05-18 tmd e 1003507108 g230ets 2015-05-31 zpaf 2015-05-18 tmd b 1003507108 g230ets 2015-05-31 zpaf 2015-05-18 tmd e 1003507109 g230ets 2015-05-31 zpaf 2015-05-18 tmd b 1003507109 g230ets 2015-05-31 zpaf 2015-05-18 tmd e 1003507110 g230ets 2015-05-31 zpaf 2015-05-18 tmd b 1003507110 g230ets 2015-05-31 zpaf 2015-05-18 tmd e 1003507111 g230ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022686 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022712 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022735 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp b 1001022748 a60ets 2016-02-29 zpaf 2016-02-12 t-home icp e 1001022760 a60ets
Comments
Post a Comment