Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (120 points)

I would like to split the column by West and East Coast states and have the Occurrences shown for both.

i'd like to get this:

```

West Coast             Occurrences              East Coast             Occurrences

California                 18108                        New York                876

Oregon                    376                            Florida                    1076

Washington             973                            Maine                      925

....

```

I tried this method:

```

#Split West and East Coast States and put them side by side: West_q & East_q
West_q = pd.DataFrame({'state': ['California', 'Oregon', 'Washington', 'Alaska'], 'Value': ['18108', '376', '973', '12326']})

West_q[['West Coast']] = West_q.state.str.split(expand=True)

```

I cant figure out how to get both, only one.

Please log in or register to answer this question.

Browse Categories

...