New York City is thought of as a town that can throw a great party, but it's known more for its New Years' celebrations and Thanksgiving Day parades than for its Halloween parties. But you shouldn't discount the idea of bobbing for apples in the Big Apple, according to a new analysis from WalletHub. After examining prices, trick-or-treating opportunities, crime rates, and other factors, WalletHub came to the conclusion that New York City is the country's best place to celebrate on October 31.

The analysis took into account 20 different metrics in three categories: trick-or-treater friendliness, Halloween fun, and Halloween weather. The metrics included factors like population density and walkability (because it's hard to trick-or-treat if you can't walk between houses) as well as crime rates and pedestrian fatality rates (because you want to feel safe letting your kids run around at night). It also took into account holiday-centric factors like the number of Halloween party stores per capita, the number of haunted houses and pumpkin patches per capita, Google results for "Halloween parties," and the price of publicly listed Halloween events for that city on Eventbrite. And, because it's hard to have fun in that ghost costume when it's snowing, it also looked at weather.

It's a little last minute to book a Halloween trip now, but if you want to have the best Halloween you can next year, keep these top-10-ranked cities in mind:

1. New York City
2. Jersey City, New Jersey
3. Los Angeles
4. Irvine, California
5. San Diego, California
6. Santa Ana, California
7. Chicago
8. Las Vegas
9. Irving, Texas
10. St. Paul, Minnesota

New York City likely topped the list thanks to its population density and walkability. But before you decide to head there for your own Halloween celebrations, keep in mind that just because there are a lot of people living in a particular area doesn't mean trick-or-treating will be a breeze—in fact, most New York City kids trick-or-treat at stores instead of houses, since resident-only high-rise apartment buildings aren't that conducive to door-to-door candy collection. Still, the city does offer a ton of other Halloween options, so we won't argue with the ranking. It's in a five-way tie for first place in the number of Halloween costume stores in the country, and tied with Honolulu for most candy stores per capita, too.

Explore how cities across the country stacked up in the interactive map below, then head to WalletHub to take a deeper dive into the data.

Source: WalletHub