Python Pandas returns different output for the same code -


i have 10,000 row csv data file, read , wish manipulate data. want loop through, , compute results in matrix form, involves taking specific columns , doing computations. everytime run same program, different results. doing wrong here? there exceptions need know? use python 3.5. also,suggest if there's better way of doing this, i'm new analyzing data pandas.

# import important stuff import numpy np # imports fast numerical programming library  import scipy sp #imports stats functions, amongst other things  import matplotlib mpl # imports matplotlib  import matplotlib.cm cm #allows easy access colormaps  import matplotlib.pyplot plt #sets plotting under plt  import pandas pd #lets handle data dataframes   #sets pandas table display  pd.set_option('display.width', 500)  pd.set_option('display.max_columns', 100)  pd.set_option('display.notebook_repr_html', true)  import seaborn sb #sets styles , gives more plotting options %matplotlib inline  # read data file rawdata=pd.read_csv("c:/users/user/../rawdata.csv")  # calculate volumetric sales - convert cubic.cm cubic meter rawdata["volumetric sales"] = rawdata["ium l"] * rawdata["ium w"] * rawdata["ium h"] * (10**-6) * rawdata["sales past week"] /7  # 0 sale items, reserve space atleast 1 unit in bartholdi's formula rawdata.loc[rawdata["volumetric sales"] == 0, "volumetric sales"] = rawdata["ium l"] * rawdata["ium w"] * rawdata["ium h"] * (10**-6)  # sort volumetric sales , change index rawdata=rawdata.sort_values(by="volumetric sales", ascending=false) rawdata.index = range(1,len(rawdata) + 1)  # find cumulative % of volumetric sales rawdata["cumulative volumetric sales"] = 100 * rawdata["volumetric sales"].cumsum() / rawdata["volumetric sales"].sum()  # find ium , pum volumes rawdata["ium volume"] = rawdata["ium l"] * rawdata["ium w"] * rawdata["ium h"] * (10**-6) rawdata["pum volume"] = rawdata["pum l"] * rawdata["pum w"] * rawdata["pum h"] * (10**-6)   # reference data - dry designorders = 1856 projectedorders = [1856, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000, 4200, 4400, 4600, 4800, 5000] referencedos = 19.41 projecteddos = [10, 12, 14, 16, 18, 19.41, 21]  # total volume of pick faces in cubic meters - changed totalpfvolume = 900  # have dummy dataframe recording volumes volumeprojections = pd.dataframe(np.zeros((len(projectedorders), len(projecteddos))), index=projectedorders, columns=projecteddos)  # loop on order-dos combinations orders in projectedorders:      dos in projecteddos:          # hold atleast 1 cs every sku, project dos , number of orders         rawdata["quantity hold"] = np.maximum(rawdata["conv qty"], np.ceil((rawdata["sales past week"] / 7) * rawdata["long-term dos"] * (dos/referencedos) * (orders/designorders)))          # calculate bartholdi ratio (for calculating volume) every sku         rawdata["bang buck volume"] = np.sqrt(rawdata["volumetric sales"]  * (dos/referencedos) * (orders/designorders) * 365)          # find total ratio         totalratio = rawdata["bang buck volume"].sum()          # replace ratio actual bfb volume         rawdata["bang buck volume"] = rawdata["bang buck volume"] / totalratio * totalpfvolume          # find out 1.2 cs volume         rawdata["minimumcsvolume"] = np.maximum(rawdata["ium volume"] * 1.2 * rawdata["conv qty"], rawdata["pum volume"])          # find out minimum pf volume dedicated         rawdata["minimumpfvolume"] = np.maximum(rawdata["bang buck volume"], rawdata["minimumcsvolume"])          volumeprojections[dos][orders] = (rawdata["quantity hold"] * rawdata["pum volume"] / rawdata["conv qty"]).sum()  print(volumeprojections) 

first time output:

            10.00        12.00        14.00        16.00           18.00        19.41        21.00 1856   461.470704   814.294089   498.952202   692.073162      767.460646   823.379664   899.881262 2000   490.722450   573.388032   654.591470   738.901730      125.450220   881.608444   949.107524 2200   488.448647   621.031090   902.686916   804.691009      898.690028   193.467034  1037.500241 2400   573.388032   671.466619   771.939732   872.041555      824.477296  1044.463665  1127.280933 2600   613.172775   721.686269   830.917824   942.274260      904.456359  1128.260223   199.670501 2800   654.591470   771.939732   888.837779  1007.957693     1127.280933  1210.356114  1303.793814 3000   697.014717   814.294089   762.973265  1076.826423     1203.418445  1291.381509  1393.277041 3200   738.901730   907.329916   814.294089  1142.877798     1279.231844  1374.000727   208.728851 3400   169.283162   922.709658  1068.259174  1211.165380     1356.711651  1458.048882   902.686916 3600   307.466789   974.235769  1127.280933  1279.231844     1430.845138  1539.624099   814.294089 3800   864.390648  1024.772862   806.131997   899.881262     1508.932226  1622.537921  1750.385991 4000   906.896879   814.294089   125.448108  1415.526353      902.686916   222.723561   246.031964 4200   949.107524  1032.639510  1303.793814  1483.680183     1662.568445  1788.231250   226.243325 4400   899.881262   296.567996   902.686916  1551.248439      814.294089  1872.211342  2021.472316 4600  1033.713507  1228.240414  1423.718589  1619.825535     1813.973271  1955.691168  2110.941821 4800  1076.826423  1279.231844  1483.680183   169.283162  1148116.618907  2036.863282  2202.442643 5000  1117.762804  1330.539197  1541.371825  1757.894289     1970.034712  2120.383575  2288.757769 

second time output:

            10.00        12.00        14.00        16.00        18.00        19.41        21.00 1856   461.470704   536.893794   613.039076   692.073162   169.283162   907.111078   885.086313 2000   428.238473   573.388032   654.591470   738.901730   814.294089   881.608444   175.021151 2200   531.236534   621.031090   169.283162   804.691009   898.690028   169.283162  1037.500241 2400   573.388032   671.466619   771.939732   872.041555   196.363519  1044.463665   902.686916 2600   902.686916   721.686269   830.917824   942.274260  1050.509828   902.686916   902.686916 2800   902.686916   771.939732   888.837779  1007.957693  1127.280933  1210.356114   202.436238 3000   697.014717   822.973094   949.107524  1076.826423  1203.418445  1291.381509  1393.277041 3200   738.901730   872.041555  1007.957693  1142.877798  1279.231844  1374.000727  1483.680183 3400   779.775957   922.709658  1068.259174  1211.165380  1356.711651  1458.048882  1574.101946 3600   822.973094   974.235769  1057.805643  1279.231844   909.019825  1539.624099  1662.568445 3800   864.390648   169.283162  1182.686040  1347.291081   814.294089  1622.537921  1750.385991 4000   906.896879  1076.826423  1244.883257  1415.526353   902.686916   814.294089  1841.840966 4200   949.107524  1127.280933   902.686916   902.686916  2351.239410  1788.231250  1930.603268 4400   991.031678   814.294089  1364.490160  1551.248439   814.294089  1872.211342  2021.472316 4600  1033.713507  1228.240414  1423.718589   169.283162  1813.973271   899.881262   902.686916 4800  1076.826423  1279.231844  1483.680183  1685.749648  1893.147718   237.532106  2202.442643 5000  1117.762804  1330.539197   241.441668  1757.894289  1970.034712   910.288608  2288.757769 


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -