0

I have a csv file that has a location column that I want to manipulate using Python. The location column has 3 values in each cell (ID, county, state). I want to clean this column so that each cell only shows ID, deleting the county and state values. For example, each cell in this column currently looks like:

[locID 1, countyname, statename], [locID 2, countyname, statename], etc...

The desired outcome is that each cell would look like:

[locID 1], [locID 2], etc...

Any help is greatly appreciated, thank you!

2
  • Is that a list of location lists you're showing or is that how the CSV file is laid out? Commented Jun 28, 2022 at 22:46
  • Welcome to SO. This isn't a discussion forum or tutorial. Please take the tour and take the time to read How to Ask and the other links found on that page. Invest some time with the Tutorial practicing the examples. It will give you an idea of the tools Python offers to help you solve your problem Commented Jun 28, 2022 at 22:48

1 Answer 1

1

You should show your code for better understanding. I don't know if you are using pandas if you are there are specific functions to do it if you're not it is possible too, you just need to replace that row with the id with a loop.

id_column = [1, 'San Antonio', 'Las Vegas']
location_column = id_column[0]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.