how to wrangle data tp achieve the data frame in the way I want?
up vote
-1
down vote
favorite
I have a data frame which looks like this:
df1 = pd.DataFrame('serialNo':['aaaa123','aaaa123','cccc789','cccc789','cvgy456','cvgy456','aaaa123'],
'code':['Sayonti','Sayonti','Tony','Tony','Toffee','Toffee','Sayonti'],
'testName': [4402, 4402 ,5555,6753,1234,9876,3602],
'moduleName': ['singing', 'singing','booze', 'booze','drama','paint','singing'],
'endResult': ['WARNING', 'WARNING', 'FAILED', 'FAILED','WARNING','FAILED','WARNING'],
'shippingno':['20179','20179','87654','87654','20179','20179','12970'],
'cofig':['GVC1','GVC1','HFY7','HFY7','RDXI','RDXI','POLK'],
'moduleLocation':['front','front','rear','rear','front','head','foot'],
'component':['12AB','12AB','BC67','BC67','12AB','12AB','BC67'],
'partno':[231,441,768,768,765,983,986])
and I want to wrangle the data such that I can achieve the output data frame to look like below:
df2 = pd.DataFrame('serialNo':['aaaa123','cccc789','cvgy456','aaaa123'],
'code':['Sayonti','Tony','Toffee','Sayonti'],
'moduleName': ['singing','booze','drama,paint','singing'],
'shippingno':['20179','87654','20179','12970'],
'cofig':['GVC1','HFY7','RDXI','POLK'],
'moduleLocation':['front','rear','front,head','foot'],
'component':['12AB','BC67','12AB','BC67'],
'partno':['231,441',768,'765,983',986],
'WARNING':[4402,0,1234,3602],
'FAILED':[0,'5555,6753',9876,0])
I can group.by(serial number) and concatenate but just not sure how to achieve an output like this as I am running into errors. Please help!
python pandas
add a comment |
up vote
-1
down vote
favorite
I have a data frame which looks like this:
df1 = pd.DataFrame('serialNo':['aaaa123','aaaa123','cccc789','cccc789','cvgy456','cvgy456','aaaa123'],
'code':['Sayonti','Sayonti','Tony','Tony','Toffee','Toffee','Sayonti'],
'testName': [4402, 4402 ,5555,6753,1234,9876,3602],
'moduleName': ['singing', 'singing','booze', 'booze','drama','paint','singing'],
'endResult': ['WARNING', 'WARNING', 'FAILED', 'FAILED','WARNING','FAILED','WARNING'],
'shippingno':['20179','20179','87654','87654','20179','20179','12970'],
'cofig':['GVC1','GVC1','HFY7','HFY7','RDXI','RDXI','POLK'],
'moduleLocation':['front','front','rear','rear','front','head','foot'],
'component':['12AB','12AB','BC67','BC67','12AB','12AB','BC67'],
'partno':[231,441,768,768,765,983,986])
and I want to wrangle the data such that I can achieve the output data frame to look like below:
df2 = pd.DataFrame('serialNo':['aaaa123','cccc789','cvgy456','aaaa123'],
'code':['Sayonti','Tony','Toffee','Sayonti'],
'moduleName': ['singing','booze','drama,paint','singing'],
'shippingno':['20179','87654','20179','12970'],
'cofig':['GVC1','HFY7','RDXI','POLK'],
'moduleLocation':['front','rear','front,head','foot'],
'component':['12AB','BC67','12AB','BC67'],
'partno':['231,441',768,'765,983',986],
'WARNING':[4402,0,1234,3602],
'FAILED':[0,'5555,6753',9876,0])
I can group.by(serial number) and concatenate but just not sure how to achieve an output like this as I am running into errors. Please help!
python pandas
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have a data frame which looks like this:
df1 = pd.DataFrame('serialNo':['aaaa123','aaaa123','cccc789','cccc789','cvgy456','cvgy456','aaaa123'],
'code':['Sayonti','Sayonti','Tony','Tony','Toffee','Toffee','Sayonti'],
'testName': [4402, 4402 ,5555,6753,1234,9876,3602],
'moduleName': ['singing', 'singing','booze', 'booze','drama','paint','singing'],
'endResult': ['WARNING', 'WARNING', 'FAILED', 'FAILED','WARNING','FAILED','WARNING'],
'shippingno':['20179','20179','87654','87654','20179','20179','12970'],
'cofig':['GVC1','GVC1','HFY7','HFY7','RDXI','RDXI','POLK'],
'moduleLocation':['front','front','rear','rear','front','head','foot'],
'component':['12AB','12AB','BC67','BC67','12AB','12AB','BC67'],
'partno':[231,441,768,768,765,983,986])
and I want to wrangle the data such that I can achieve the output data frame to look like below:
df2 = pd.DataFrame('serialNo':['aaaa123','cccc789','cvgy456','aaaa123'],
'code':['Sayonti','Tony','Toffee','Sayonti'],
'moduleName': ['singing','booze','drama,paint','singing'],
'shippingno':['20179','87654','20179','12970'],
'cofig':['GVC1','HFY7','RDXI','POLK'],
'moduleLocation':['front','rear','front,head','foot'],
'component':['12AB','BC67','12AB','BC67'],
'partno':['231,441',768,'765,983',986],
'WARNING':[4402,0,1234,3602],
'FAILED':[0,'5555,6753',9876,0])
I can group.by(serial number) and concatenate but just not sure how to achieve an output like this as I am running into errors. Please help!
python pandas
I have a data frame which looks like this:
df1 = pd.DataFrame('serialNo':['aaaa123','aaaa123','cccc789','cccc789','cvgy456','cvgy456','aaaa123'],
'code':['Sayonti','Sayonti','Tony','Tony','Toffee','Toffee','Sayonti'],
'testName': [4402, 4402 ,5555,6753,1234,9876,3602],
'moduleName': ['singing', 'singing','booze', 'booze','drama','paint','singing'],
'endResult': ['WARNING', 'WARNING', 'FAILED', 'FAILED','WARNING','FAILED','WARNING'],
'shippingno':['20179','20179','87654','87654','20179','20179','12970'],
'cofig':['GVC1','GVC1','HFY7','HFY7','RDXI','RDXI','POLK'],
'moduleLocation':['front','front','rear','rear','front','head','foot'],
'component':['12AB','12AB','BC67','BC67','12AB','12AB','BC67'],
'partno':[231,441,768,768,765,983,986])
and I want to wrangle the data such that I can achieve the output data frame to look like below:
df2 = pd.DataFrame('serialNo':['aaaa123','cccc789','cvgy456','aaaa123'],
'code':['Sayonti','Tony','Toffee','Sayonti'],
'moduleName': ['singing','booze','drama,paint','singing'],
'shippingno':['20179','87654','20179','12970'],
'cofig':['GVC1','HFY7','RDXI','POLK'],
'moduleLocation':['front','rear','front,head','foot'],
'component':['12AB','BC67','12AB','BC67'],
'partno':['231,441',768,'765,983',986],
'WARNING':[4402,0,1234,3602],
'FAILED':[0,'5555,6753',9876,0])
I can group.by(serial number) and concatenate but just not sure how to achieve an output like this as I am running into errors. Please help!
python pandas
python pandas
asked Nov 10 at 0:42
sayo
297
297
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235013%2fhow-to-wrangle-data-tp-achieve-the-data-frame-in-the-way-i-want%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown