I have a dictionary looks like this
aspek = {
'responsivitas' : ['keluhan', 'cepat', 'responsif', 'relevan', 'tanggap'],
'kejelasan' : ['jelas', 'terperinci', 'layanan', 'pelayanan', 'biaya', 'informasi'],
'kemudahan' : ['mudah', 'daftar', 'obat', 'konsultasi', 'dokter', 'registrasi', 'sulit', 'cepat'],
'keramahan' : ['ramah', 'dokter', 'apoteker', 'petugas', 'marah', 'baik', 'rendah hati', 'senyum'],
'keamanan' : ['aman', 'data', 'privacy', 'informasi', 'layanan']
}
and asume i have a dataframe like
Result content : [ 'keluhan xxxxx','mudah asdasdasd','hasdawd jelas','asdasdwasd','aman nih']
what i've made is
Res = df['Result content']
for i in Res:
for k, v, in aspek.items():
if i in v:
df[k] = i
the output is enter image description here
what want is if my df has same value with a list in my dictionary, it will copy the dataframe to the new dataframe.
SOMEONE HELP ME
Res = df['Result content']
for i in Res:
for k, v, in aspek.items():
if i in v:
df[k] = i
what want is if my df has same value with a list in my dictionary, it will copy the dataframe to the new dataframe.
source https://stackoverflow.com/questions/76048594/match-dictionary-value-with-dataframe-and-make-new-column-if-its-match
Comments
Post a Comment