Re: pandas split and melt()

2019-06-26 Thread Peter Otten
Sayth Renshaw wrote: > Peter Otten wrote: >> def explode_consultants(consultants): Should have called that split_consultants(); takes a string and >> consultants = (c.lstrip("#") for c in consultants.split(";")) splits by ";", removes leading "#" >> return (c for c in consult

Re: pandas split and melt()

2019-06-26 Thread Sayth Renshaw
> > Since I didn't find a cool shortcut I decided to use brute force: > > $ cat pandas_explode_column.py > import pandas as pd > > df = pd.DataFrame( > [ > [ > "2019-06-21 11:15:00", > "WNEWSKI, Joan;#17226;#BALIN, Jock;#18139;#DUNE, Colem;#17230;" >

Re: pandas split and melt()

2019-06-26 Thread Peter Otten
Sayth Renshaw wrote: > Hi > > Having fun with pandas filtering a work excel file. > My current script opens selected and filters the data and saves as excel. > > import pandas as pd > import numpy as np > > log = pd.read_excel("log_dump_py.xlsx") > df = log.filter(items=['Completed', 'Priority'

Re: pandas split and melt()

2019-06-26 Thread Sayth Renshaw
Update. Option 1. - This annihilates all text in the column leaving nothing. completed_tasks['Consultant'] = completed_tasks['Consultant'].str.rstrip('.#123') Option 2. - returns unhashable series list. output = completed_tasks[completed_tasks['Consultant']].str.contains(r'/\b[^\d\W]+\b/g')

Re: pandas split and melt()

2019-06-25 Thread Sayth Renshaw
> > NB. There are varied amounts of consultants so splitting across columns is > > uneven. if it was even melt seems like it would be good > > https://dfrieds.com/data-analysis/melt-unpivot-python-pandas > > Keep it simple: https://docs.python.org/3.6/library/string.html > > -- > Regards =dn

Re: pandas split and melt()

2019-06-25 Thread DL Neil
On 26/06/19 6:13 PM, Sayth Renshaw wrote: Hi Having fun with pandas filtering a work excel file. My current script opens selected and filters the data and saves as excel. ... This leaves me with a set of several columns. The main column of concern for this example is a consultant Session date