РЕДАКТИРОВАТЬ: Ответ на вопрос см. Мой код ниже для ответа.Я забыл добавить
df = df.melt(id_vars=['Gender', 'Length of service', 'Team'],
value_vars=Questions,
var_name='Question',
value_name='Result')
Я пытался использовать функцию плавления в Пандах с ограниченным эффектом.
Я пытаюсь получить 36 вопросов, которые разделены настолбцы в строках 36 для каждого идентификатора.
import pandas as pd
Questions = ['How likely are you to you recommend the company as a place to work to a friend or colleague? ',
'How satisfied are you in working at the company?','My work gives me a feeling of personal accomplishment',
'I know what is expected of me and I have clearly defined goals','I have the tools and resources to do my job well',
'My job makes good use of my skills and abilities',
'I receive the training I need to do my job well',
'There are adequate opportunities for career growth in this organisation',
'I understand the business priorities and how my job can help',
'I get the right level of support from my Manager',
'I receive useful and constructive feedback from my Manager',
'I receive the praise and recognition I deserve from my Manager',
'My Manager is interested in my professional development and advancement',
'My Manager treats everyone in the team fairly',
'My Manager listens to what I\'m saying',
'I feel comfortable voicing my concerns to my Manager',
'My Manager keeps me well informed of what is happening',
'I have confidence in the Executive Team to lead the company',
'The Executive Team listens to and responds to the needs of employees',
'I feel I can easily approach and communicate with members of the Executive Team',
'The Executive Team at the company leads by example',
'The Executive Team keeps the company well informed of what is happening',
'This Company supports a good work life balance',
'The pace of the work in this Company enables me to do a good job',
'The amount of work I am asked to do is reasonable',
'My job does not cause unreasonable amounts of stress in my life',
'My team work well together and support each other when needed',
'Everybody is treated fairly in this Company',
'Poor performance is effectively addressed throughout this Company',
'I can disagree with my manager without fear of getting in trouble',
'I am comfortable sharing my opinions at work','Diversity is valued at the company',
'I am proud to work for the company','I am paid fairly for the work I do',
'My salary is competitive with similar jobs I might find elsewhere',
'My benefits are comparable to those offered by other Companies']
df = pd.read_excel(r'Survey.xlsx')
df.melt(id_vars=['Gender', 'Length of service', 'Team'],
value_vars=Questions,
var_name='Question',
value_name='Result')
df.to_csv(r'FINAL_OUTPUT.csv', index=False)
Однако приведенный выше код, похоже, не имеет никакого эффекта. Я приложил файл .zip с Survey.xlsx и соответствующим кодом .Я рандомизировал данные, поэтому в них нет ничего чувствительного.
Есть идеи?
Спасибо.