我有一个Pandas DataFrame值(浮点数)和国家名称字符串("UNITED STATES","UNITED KINGDOM"等).我想根据国家总结价值观:
Data['Values'].groupby(Data['Country']).sum()
Run Code Online (Sandbox Code Playgroud)
不幸的是,我收到以下错误:
TypeError: 'Series' objects are mutable, thus they cannot be hashed
Run Code Online (Sandbox Code Playgroud)
此外,如果我尝试将由国家/地区组成的系列独一无二:
Data['Country'].unique()
Run Code Online (Sandbox Code Playgroud)
我犯了同样的错误:
TypeError: 'Series' objects are mutable, thus they cannot be hashed
Run Code Online (Sandbox Code Playgroud)
为什么会出现此错误?这是国名吗?任何帮助将不胜感激.我使用的是Python 3.4和Pandas 0.15.2.
我正在使用 python-docx 将 Pandas DataFrame 输出到 Word 表。大约一年前,我编写了这段代码来构建那个当时有效的表:
table = Rpt.add_table(rows=1, cols=(df.shape[1]+1))
table.style = 'LightShading-Accent2'
Run Code Online (Sandbox Code Playgroud)
Rpt模板中的文档在哪里。现在,我收到一个错误:
KeyError: "no style with name 'LightShading-Accent2'"
Run Code Online (Sandbox Code Playgroud)
我应该如何定义风格?较新版本的 python-docx 中的命名约定是否发生了变化?