May-31-2019, 09:13 AM
I have csv file with fake data. This is part:
I thought about something like that:
Quote:Name1,Telephone1,Name2,Telephone2,DurationI want to create two columns, the first one with all name and the second one with all telephone numbers.
Alice,085 646 4923,Shawn,085 388 3678,7
Derek,082 467 5217,Justin,082 245 8825,9
Derek,082 467 5217,Kim,083 278 8489,48
Benjamin,084 614 6635,Henry,084 233 5472,15
David,084 852 1646,Helen,085 962 5673,17
Joseph,085 655 8640,Elva,082 984 4322,44
Alvin,083 268 1145,Cheryl,085 140 6517,2
Henry,084 233 5472,Justin,082 245 8825,40
Karla,083 936 4576,Ann,083 403 7003,35
Henry,084 233 5472,Nicole,085 448 3607,39
Steven,082 792 4993,John,084 340 3759,13
Kenya,083 464 8078,Kim,083 278 8489,16
Alfred,085 749 1638,Samuel,084 603 8830,48
Mac,083 176 7486,Phyllis,084 638 7641,11
Donna,085 532 8752,Brandon,085 402 7641,23
Alvin,083 268 1145,Jennette,083 227 5242,14
I thought about something like that:
import pandas as pd import numpy as np dane=pd.read_csv('telephone_calls.csv') names=pd.DataFrame(dane,columns=['Name1','Name2']) print(names.unstack()) numbers=pd.DataFrame(dane,columns=['Telephone1','Telephone2']) print(numbers.unstack())But it does work as it should.