如何将此字典值放入名为 'municipality' 的数据框的新列中?

how do i put this dictionary values in a new column of a dataframe called 'municipality'?

我已经从名为 'mun_dict' 的字典中提取了这些值,现在我想获取这些提取的值,然后将它们放入我的数据框的一个新列中,该列有 200 个索引,但mun_dict 只有 7 个。

我想将 mun_dict 值放入新列中,然后在找不到市政当局时使用 'np.nan'。

我试过了,但它返回了这个错误:'Length of values (2) does not match length of index (200)'

这是我试过的代码,

mun_dict.values()

twitter_df['municipality'] =[mun_dict.values(), np.nan]

twitter_df[['municipality']]
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\common.py in require_length_match(data, index)
    529     """
    530     if len(data) != len(index):
--> 531         raise ValueError(
    532             "Length of values "
    533             f"({len(data)}) "

ValueError: Length of values (2) does not match length of index (200)

这会将值放在前 7 行,其余为 np.nan

twitter_df['municipality'] = list(mun_dict.values()) + list(np.nan * np.ones(len(twitter_df)-len(mun_dict.values())))