Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connecting data
#1
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

Attached Files

.xlsx   example.xlsx (Size: 9.13 KB / Downloads: 271)
Reply
#2
#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()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020