ile dataframe verileri düzenlemek için tüm dizeleri çoğaltıldığı yıl 2014
ve 2015
içinNasıl pandalar
used_at common users pair of websites
0 2014 1364 avito.ru and e1.ru
1 2014 1364 e1.ru and avito.ru
2 2014 1716 avito.ru and drom.ru
3 2014 1716 drom.ru and avito.ru
4 2014 1602 avito.ru and auto.ru
5 2014 1602 auto.ru and avito.ru
6 2014 299 avito.ru and avtomarket.ru
7 2014 299 avtomarket.ru and avito.ru
8 2014 579 avito.ru and am.ru
9 2014 579 am.ru and avito.ru
gibi Dataframe var. İlk çıkış 2014
ve sonra 2015
Her çiftten yinelenen dizeleri silmek istediğiniz
used_at common users pair of websites
0 2014 1364 avito.ru and e1.ru
1 2015 1208 avito.ru and e1.ru
2 2014 1716 avito.ru and drom.ru
3 2015 897 avito.ru and drom.ru
gibi benim verilerini yazdırmak ve bunun yerine yazdırmak gerekiyor. Bunu yapmaya çalıştım:
all_common_users = df.groupby([df['used_at'].dt.year]).apply(f).reset_index(drop=True, level=1).reset_index()
common_users = all_common_users.groupby(all_common_users.index/2).first().sort_values('pair of websites')
# keep only 'interesting' columns
common_users = common_users[['pair of websites','used_at','common users']]
common_users.columns = ['pair of websites','year','common users']
df = common_users[common_users.groupby('pair of websites')['common users']].sort_values('pair of websites', ascending=False).reset_index()
Ama yanlış yazdırır. Neyi yanlış yaptım?
Yinelenen dizeleri silin. "Web siteleri çifti" ile nasıl sıralanabilir? Ben sort_values ('web siteleri çifti, artan = Yanlış') 'ı deneyin ama tüm çiftler sıralanmadı. Bazıları, –
numaralı siparişin dışındadır. Aksi halde sahip olduklarınız, istediğin ve denediğin şeyle başka bir soru sor. – jrjc
@ user116873 soruyu cevaplarsa kabul edin, böylece diğerleri sorununuzu çözdüğünü bileceklerdir. – jrjc