in reply to Re: Creating One Table From Several Hashes
in thread Creating One Table From Several Hashes

Hey-

I was wondering if I could get some additional advice. I have been working with your code, and I have ran into a slight problem. It seems as though this routine is creating a new date column for each zipcode entry instead of summing the amounts of money for each date and zipcode. The end results is a symmetric matrix, with the columns equaling the number of zipcodes. This is not what should happen. Instead, I was envisioning a matrix with the rows equaling the number of zip codes and the columns equaling the number of dates. I have limited the data set to 4000 zipcodes and 60 days, so the matrix should be 4000 X 60, with each cell representing the total amount of money for that zipcode at that day. So (1,1) => Zipcode 12345 total contribution for 09012000, (1,2) => zipcode 12345 total contribution for 09022000, (2,1) => zipcode 12346 total contribution for 09012000, you get the idea. Instead what I get is a matrix 4000 X 4000, which seems to create new dates for each new zipcode entry. I think what is going on is a keying problem with the hash. Instead of recognizing 09012000 = 09012000 it assumes 09012000 != 09012000 and it is creating a new column 09012000.1 instead of grouping the dates together. Do you have any thoughts on this matter? Thanks.
  • Comment on Re^2: Creating One Table From Several Hashes

Replies are listed 'Best First'.
Re^3: Creating One Table From Several Hashes
by ikegami (Patriarch) on Mar 05, 2009 at 20:36 UTC

    I was envisioning a matrix with the rows equaling the number of zip codes and the columns equaling the number of dates.

    That's what it does. From my earlier post,

    CANDID ZIP MONEY (11062000) MONEY (11072000) C1234 12345 250 0 C1234 33480 0 0 C1234 38401 0 0 C1234 67890 0 0 C1234 75711 0 0 C1234 77024 0 0

    6 zips, so 6 rows.
    2 dates, so 2 cols.

    Note that 250 is the sum of two different amounts.

    Instead what I get is a matrix 4000 X 4000

    Not using my code, you didn't. As for the problem with your code, I don't know what you're expecting from me without showing me the code.

      You were right.

      It wasn't a code issue, it was a data issue. For some reason when I filtered the data in order to exclude all but a few dates it didn't work. I forgot to check it before running the script...lesson learned. I figured out the filter issue, and now everything is copacetic. Thanks again for the help, and sorry for not including my code. I was sort of in a scramble mode after a very long day of working on this project.