I have a column that is like this: date key name email summary stats date name age where date summary age name . that continues through multiple columns thats in one row. that has no particular length but every new document starts with date. How can I use reshape or use another method to parse the row into a new rows on that key word date. I am trying take a document that is stretch in excel through multiple columns in one row and change it to a data frame with multiple rows and columns starting with date keyword as first column.
You can use split()
for example:
string_data = "date key name email summary stats date name age where date summary age name date name age where date summary age name"
split_string = string_data.split("date")
for rows in split_string[1:]:
rows = "date" + rows
print rows
will output:
date key name email summary stats
date name age where
date summary age name
date name age where
date summary age name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.