in Education by
0 2 ['name:', 'Atlanta', 'GA:', 'Hartsfield-Jackson', 'Atlanta', 'International'] 35 ['name:', 'Boston', 'MA:', 'Logan', 'International'] 68 ['name:', 'Baltimore', 'MD:', 'Baltimore/Washington', 'International', 'Thurgood', 'Marshall'] 101 ['name:', 'Charlotte', 'NC:', 'Charlotte', 'Douglas', 'International'] 134 ['name:', 'Washington', 'DC:', 'Ronald', 'Reagan', 'Washington', 'National'] 167 ['name:', 'Denver', 'CO:', 'Denver', 'International'] 200 ['name:', 'Dallas/Fort', 'Worth', 'TX:', 'Dallas/Fort', 'Worth', 'International'] 233 ['name:', 'Detroit', 'MI:', 'Detroit', 'Metro', 'Wayne', 'County'] 266 ['name:', 'Newark', 'NJ:', 'Newark', 'Liberty', 'International'] 299 ['name:', 'Fort', 'Lauderdale', 'FL:', 'Fort', 'Lauderdale-Hollywood', 'International'] 332 ['name:', 'Washington', 'DC:', 'Washington', 'Dulles', 'International'] I have this series above and I want to split each row so that it lists everything like; Atlanta GA: Hartsfield-Jackson Atlanta International. This would be one column in a data frame. Essentially just want to remove the 'name:' at the beginning of each row and then split it so I have the form that I want. I have tried my_series.str.split("'").str[7].reset_index(drop=True).astype(str) But my output comes out to 0 0 Hartsfield-Jackson 1 Logan 2 Baltimore/Washington 3 Charlotte 4 Ronald 5 Denver 6 TX: 7 Detroit 8 Newark 9 FL: 10 Washington JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Hey comeyougunners10, Just as Barmar suggested, you are not dealing with a string; instead, I suspect you are dealing with the list as the value in each cell. Just do a quick test yourself, and see if the result is a list: type(df.iloc[index_of_this_column,0]) If you are indeed dealing with lists, then here is how I will approach it. def pandas_list_str_spliter(input_value): # we use the join function to turn list into the str # From here, you should be able to do any transformation you need # I only removed the "name:" and front & tailing whitespace. # But you can modify the function to suit your need return ' '.join(input_value).replace('name:','').strip() df['Column_Split'] = df['Column_Split'].apply(pandas_list_str_spliter) I hope this can be helpful.

Related questions

0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    How do I get the index column name in python pandas? Here's an example dataframe: Index Title Column 1 Apples 1 ... how to do this? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I'm starting from the pandas DataFrame docs here: http://pandas.pydata.org/pandas-docs/stable/dsintro.html I'd ... =1)] print valdict Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Hello I am quite new to pygame and I am trying to make an intro for a game where the user hovers ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I want my Python function to split a sentence (input) and store each word in a list. My current code splits ... the word print(words) Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Is there any way to split the string if it contains an uppercase letter but not the first letter? For example, ... solution to it? Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    import re text = 'The quick. black n brown? fox jumps*over the lazy dog.' print(re.split('; | ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    import re text = 'The quick. black n brown? fox jumps*over the lazy dog.' print(re.split('; | ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    import re text = 'The quick. black n brown? fox jumps*over the lazy dog.' print(re.split('; | ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    import re text = 'The quick. black n brown? fox jumps*over the lazy dog.' print(re.split('; | ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    In a list with range(1,16) and I am trying to divide this list in some fixed numbe n . Let's assume n=7 ... uneven, How can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I have an array of the shape (100000, 1) with each element in an array of type positive integer and not ... help would be appreciated. Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Pandas Merging 101 (6 answers) Closed 3 years ago. Sorry guys, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
...