Python Forum

Full Version: connecting data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi guys,

how can i connect data so it would be all together (there should be 100 rows)


however, when i am trying to run the script it shows 200 rows
empty_list = []
excel = pd.read_excel('Excel.xlsx')

survey = excel['Survey']
something = excel['Something_header']

for index, value in enumerate(something):
    while value == '' or (isinstance(value, float) and  math.isnan(value)):
        value = something[index]
        index = index - 1    
    dict = {'something': value}
    empty_list.append(dict)

    
    
for survey_index, survey_value in enumerate(survey):
    while survey_value == '' or (isinstance(survey_value, float) and  math.isnan(survey_value)):
        survey_value = survey[survey_index]
        survey_index = survey_index - 1   
    dict2 = {'Survey': survey_value}
    empty_list.append(dict2)

df = pd.DataFrame(empty_list, columns=['Survey', 'something'])
print(df)
#edit

ok i think i got it, probably should have created 2 df and then concatenate them
#didnt work out :P
#refresh
Any tips guys? i am trying to do it in different way but really got problem with it

#refresh #2

Ok, i figured it out.
I needed to start everything with iterrows()