i just learn the basic in Panda and im looking a way to concat and delete nan value and get the result in a new column of my dataframe.
I know how to concat, how to create list but not realy how to iterate trought the column delete the nan value and finally concat the result in the new column.
i have a table with different number and i would like to create a column with panda (CONTACT[CALLER_PHONE] = ...) with all the number from each row and no null values. Exemple of result that i want in a table:
Number1 Number2 Number3 CALLER_PHONE
0675416952 0675416941 0675416930 0675416952,067541694,0675416930
Nan 0675417080 0675417082 0675417080,0675417082
Nan Nan 0675837759 0675837759
My Code :
import pandas as pd
CONTACT = pd.read_excel('O:/16_GIS_Team/X_Tools/Model Builder And Parcels Package/Contact_20200807/CONTACT_20200807.xlsx')
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
CONTACT['CALLER_NAME'] = CONTACT['First Name'].str.cat(CONTACT['Last Name'], sep =" ")
cols = CONTACT[['Work Phone','Mobile','Home Phone','SMS marketing phone','Other Phone Number','Details (USA): Caller Phone']]
print(cols)
columns = list(cols)
for i in columns:
Clean_Columns = cols.dropna(axis=1, how='any')
print (Clean_Columns[i][2])
My files is an Excel CONTACT is my dataframe
I try to iterate trought the column, than use dropna and get a cain of result with the list but its not working and i didn't dig deeper.
Error with my list peace of code
Im open to any advise thank you very much by advance!