回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在探索一个数据集,只想在受试者回答X(在本例中为“可爱”)时才使用“性”列的模式</p>
<p>到目前为止,我已经用以下逻辑做了一些事情。从“性”中得到了假人,有一个“男性”(0,1)栏。从那里,我试着做</p>
<pre><code>i_1_1 = clean_USA['Male'][clean_USA['Image1_1']=='cute']
i_mode = i_1_1.mode()
</code></pre>
<p>我试过几次,但还是失败了。这次我得到了“keyrerror:'Male'”作为输出。也许R中的这个看起来像:</p>
<pre><code>i_1 <- mode(clean_USA$Male(clean_USA$Image1_1=='cute'))
</code></pre>
<p>也许,也许不是。我刚刚开始编写代码,所以我非常感谢您的建议。你将如何解决这个问题</p>
<p>这是我的df负责人:</p>
<pre><code>{'Nationality': {0: 'United States',
1: 'United States',
2: 'United States',
3: 'United States',
4: 'United States'},
'Sex': {0: 'Female', 1: 'Female', 2: 'Female', 3: 'Female', 4: 'Female'},
'Age': {0: 62, 1: 43, 2: 47, 3: 26, 4: 34},
'Image1_1': {0: 'noun', 1: 'cute', 2: 'cute', 3: 'noun', 4: 'pretty'},
'Image1_2': {0: 'cute', 1: 'happy', 2: 'lovely', 3: 'noun', 4: 'stunning'},
'Image1_3': {0: 'happy', 1: 'clean', 2: 'crazy', 3: 'verb', 4: 'cute'},
'Image2_1': {0: 'noun', 1: 'beautiful', 2: 'nice', 3: 'happy', 4: 'cute'},
'Image2_2': {0: 'calm', 1: 'nice', 2: 'funny', 3: 'noun', 4: 'calm'},
'Image2_3': {0: 'funny', 1: 'happy', 2: 'excited', 3: 'good', 4: 'lovely'},
'Image3_1': {0: 'noun', 1: 'beautiful', 2: 'verb', 3: 'noun', 4: 'gorgeous'},
'Image3_2': {0: 'happy', 1: 'happy', 2: 'faithful', 3: 'young', 4: 'elegant'},
'Image3_3': {0: 'excited', 1: 'verb', 2: 'funny', 3: 'teen', 4: 'knockout'},
'Image4_1': {0: 'noun', 1: 'worried', 2: 'super', 3: 'sad', 4: 'lovely'},
'Image4_2': {0: 'noun', 1: 'lazy', 2: 'nice', 3: 'noun', 4: 'cute'},
'Image4_3': {0: 'funny', 1: 'cute', 2: 'kind', 3: 'noun', 4: 'lovely'},
'Image5_1': {0: 'noun', 1: 'cute', 2: 'crazy', 3: 'noun', 4: 'taking'},
'Image5_2': {0: 'cute', 1: 'happy', 2: 'cute', 3: 'noun', 4: 'bonny'},
'Image5_3': {0: 'calm', 1: 'nice', 2: 'lovely', 3: 'noun', 4: 'exquisite'},
'Image6_1': {0: 'noun', 1: 'wonderful', 2: 'colorful', 3: 'happy', 4: 'good'},
'Image6_2': {0: 'verb', 1: 'nice', 2: 'great', 3: 'positive', 4: 'fine'},
'Image6_3': {0: 'calm',
1: 'happy',
2: 'temporary',
3: 'optimistic',
4: 'nice'},
'Image7_1': {0: 'old', 1: 'clean', 2: 'lucky', 3: 'noun', 4: 'noun'},
'Image7_2': {0: 'noun', 1: 'chubby', 2: 'obedient', 3: 'verb', 4: 'likely'},
'Image7_3': {0: 'calm', 1: 'happy', 2: 'verb', 3: 'old', 4: 'nonword'},
'Image8_2': {0: 'verb', 1: 'sweet', 2: 'tasty', 3: 'bake', 4: 'smooth'},
'Image8_3': {0: 'taste', 1: 'nice', 2: 'delicious', 3: 'noun', 4: 'soft'},
'Male': {0: 0, 1: 0, 2: 0, 3: 0, 4: 0}}
</code></pre>
<p>谢谢</p>