I have a dictionary named cities with key value pair; zip-code:city and a numpy array named arrRent with lists of 16 rents for each zip-code. What I want to do is to pair the city with a list of rents into another dictionary.
My code:
def cityPriceDict(self):
count = 0
cityprices = {}
for key, city in self.cities.items():
cityprices[city] = self.arrRent[count]
count += 1
When I print the cityprices, it only prints out the last city in the dictionary paired with the first rent list. Not sure why any help would be appreciated.
zipCity.csv:
95136,San Jose
95134,San Jose
95131,San Jose
95129,San Jose
95128,San Jose
95126,San Jose
95125,San Jose
95123,San Jose
95117,San Jose
95112,San Jose
95110,San Jose
95054,Santa Clara
95051,Santa Clara
95050,Santa Clara
95035,Milpitas
95032,Los Gatos
95014,Cupertino
95008,Campbell
94306,Palo Alto
94089,Sunnyvale
94087,Sunnyvale
94085,Sunnyvale
94043,Mountain View
94040,Mountain View
rent.csv:
2659,2623.5,2749.5,2826.5,2775,2795,2810,2845,2827,2847,2854,2897.5,2905,2925,2902.5,2869.5
3342.5,3386,3385,3353,3300,3190,3087.5,3092,3170,3225,3340,3315,3396,3470,3480,3380
2996,2989,2953,2950,2884.5,2829,2785,2908,2850,2761,2997.5,3020,2952,2997.5,2952,2923.5
2804.5,2850.5,2850,2850,2867,2940,2905,2945,2938,2860,2884,2946,2938,2986.5,2931.5,3032.5
2800,3074,2950,2850,2850,2875,2757,2716,2738.5,2696,2809,2891,3000,2960,2950,2831
3215,3250,3290,3260,3200,3350,3507.5,3301,3276,3320,3550,3500,3530,3498.5,3505,3605
2597.5,2649,2625.5,2890,3325,3200,3010,2850,2800,2745,2695,2695,2850,2850,2860,2695
2783.5,2800,2812,2809,2813.5,2817,2815,2849,2850,2927,2810,2890,2910,2996,2950,2897
2350,2350,2350,2475,2400,2495,2567.5,2525,2400,2350,2487.5,2395,2397.5,2450,2562.5,2500
3152.5,3015,3060,3027.5,2950,3000,3002.5,3022.5,2865,2850,2825,2895,3020,3022.5,3110,3185
3337,3500,3484,3519,3393.5,3295,3062.5,3057,3123.5,3103,3079,3216,3221,3200,3214,3405.5
3180,3325,3495,3488.5,3271.5,3216,3235,3216,3300,3405,3388.5,3600,3915,3629.5,3541,3405
2800,3049,3000,3032,2995,2987.5,2850,3000,3000,2895,2992.5,3080,3378.5,3094.5,3056,3150
2871.5,2850,2751,2710,2800,2875,2845,2700,2784.5,2749,2800,2875,2905,3028,3100,3100
3552.5,3550,3540,3510,3495,3510,3512.5,3525,3300,3270,3250,3182.5,3200,3200
,3250,3200
3397.5,3389,3450,3400,3300,3500,3495,3497.5,3395,3595,3350,3350,3425,3399.5,3364.5,3325.5
3550,3472,3493,3344.5,3332,3251,3270.5,3358,3370.5,3465.5,3495,3495,3500,3495,3458,3550
2805,2833,2900,2930,2795,2800,2890,2949,2800,2850,2839,2900,2850,2995,3087.5,2950.5
3495,3530,3610,4200,3990,3925,4000,3785,3792.5,3525,3495,3850,3900,4137.5,4000,4200
3545,3355,3305,3143,3220,3200,3180,3639,3260,3265,3510,3575,3695,3482.5,3600,3292.5
2995,3180,3225,3204,3219,3109,2998.5,2995,3200,3193.5,3161,3195,3200,3338.5,3200,3176
3599,3641,3796,3650,3552.5,3570,3535,3465,3400,3316,3640,3770,3440,3790,3815,3692.5
3500,3509.5,3519,3717.5,3495,3435,3285,3162.5,3425,3375,3410,3472.5,3600,3980,3657.5,3650
3773,3696,3708,3778,3689,3625,3516,3518.5,3647,3596,3685,3945,3811,3848,3699,4021.5
