(Python 2.7, using datasets from <http://www.policemisconduct.net/databases/>, 2009, 2010)

[[YOU CAN SKIP DOWN TO \_\_\_\_ IF YOU DON'T CARE ABOUT NATURE OF MY DATA]]

I'm fairly new to Python and programming in general - I'd like someone to explain the results I'm getting from my loop.

I'm trying to loop through the 'location' column of a police misconduct dataset. Its format is as follows:

city, state, USA

(I'm aware the URL above has the data broken into separate 2009 and 2010 files, where the location is already in 2 separate columns, as well as a Google Fusion to which I am referring. This question is specifically about how to make A look like B, as well as the errors I'm throwing and why.)

---

Allow me a simplified version of my question. Consider the following five locations in test.csv:

```
Tallahassee, Florida, USA
Denver, Colorado, USA
Watertown, New York, USA
Kalamazoo, Michigan, USA
Toronto, Ontario, Canada

```

I run the follow script:

```
def censor(text, word):
    texts = str(text)
    words = texts.split() #creates the list
    x = "" * len(word) #creates the stars with correct length
    for i in range(len(words)):
        if words[i] == word: 
            words[i] = x #replace
    return "".join(words)

places = pd.read_csv(test.csv) #the 5-place list above
censor(places,"USA")

```

And get the following 

```
'Tallahassee,Florida,0Denver,Colorado,1Watertown,NewYork,2Kalamazoo,Michigan,3Toronto,Ontario,Canada'

```

Obviously, the numbers shouldn't be there; it's one big long string (but an array [] instead of "" string throws errors when trying to use the .split method...); Even the spaces I want were dropped. 

Adding an alpha character in the return line ""string.join(words) as I tinkered made me even more confused about the loop I had written... (so now line 8 reads: 'return "a".join(words)')

'Tallahassee,aFlorida,aa0aDenver,aColorado,aa1aWatertown,aNewaYork,aa2aKalamazoo,aMichigan,aa3aToronto,aOntario,Canada' 

...and the only thing that does well is make me sound like Luigi when I read it. 

How can I make a) a two, separate nx1 arrays, where n is the number of observations in each array for State and City, and b) one nX2 array with analogous columns...

Thanks! (And sorry for n3wb? :(