如何处理这样的错误?

时间:2018-06-17 11:14:54

标签: python-3.x pandas pandas-datareader

User.Identity

我收到此错误,请说明应该尝试哪些方法。

(User.Identity as ClaimsIdentity).FindFirst("userId")?.Value

2 个答案:

答案 0 :(得分:1)

在macOS上尝试编码为'latin1'

companies = pd.read_csv("http://www.richardmuir.com/data/public/csv/CompaniesRevenueEmployees.csv",
                        index_col=0,
                        encoding='latin1')

答案 1 :(得分:0)

下载文件并在notepad++中打开它显示它是ansi编码的。如果你在Windows系统上,这应该解决它:

import pandas as pd

url = "http://www.richard-muir.com/data/public/csv/CompaniesRevenueEmployees.csv"

companies = pd.read_csv(url, index_col = 0, encoding='ansi')

print(companies)

如果不是(在Windows上),您需要研究如何将ansi编码的文本转换为您可以阅读的内容。

请参阅:https://docs.python.org/3/library/codecs.html#standard-encodings

输出:

                                       Name              Industry  \
0                                   Walmart                Retail
1                             Sinopec Group           Oil and gas
2      China National Petroleum Corporation           Oil and gas
...                                     ...                   ...
47               Hewlett Packard Enterprise           Electronics
48                               Tata Group          Conglomerate

    Revenue (USD billions)  Employees
0                      482    2200000
1                      455     358571
2                      428    1636532
...                    ...        ...
47                     111     302000
48                     108     600000