I'm on the birth control pill, so honestly, I'm never surprised by my period. But for people who aren't on the pill, the best way to avoid being shocked by a visit from Aunt Flo is to keep written track of your cycles. If you want, you can buy a special calendar or just use one you already have. Make a little dot or other symbol on the calendar for each day of your period. You could also track your cycle for free online with sites like mymonthlycycles.com or with iPhone apps like PMS Buddy. After tracking your cycles for a few months, you should get a pretty good idea of how long your cycles are, and how many days are in between them. You'll have a better idea of when you're due and won't be surprised.
I can also usually tell if my period is coming because I get light cramping. If you've tried tracking your cycles, but if they're just too irregular to predict, consider talking to your healthcare professional. Also, I always, always keep a tampon or pad in my purse just in case (also comes in handy for friends' emergencies!).
iPhone is a registered trademark of Apple, Inc.