我有一个奇怪的问题,我不知道该如何处理。我基本上是在调用一个json端点,结果如下:
{'Address': 'One Apple Park Way, Cupertino, CA, United States, 95014',
'AddressData': {'City': 'Cupertino',
'Country': 'United States',
'State': 'CA',
'Street': 'One Apple Park Way',
'ZIP': '95014'},
'CIK': '0000320193',
'CUSIP': '037833100',
'Code': 'AAPL',
'CountryISO': 'US',
'CountryName': 'USA',
'CurrencyCode': 'USD',
'CurrencyName': 'US Dollar',
'CurrencySymbol': '$',
'Description': 'Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. It also sells various related services. The company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, HomePod, iPod touch, and other Apple-branded and third-party accessories. It also provides AppleCare support services; cloud services store services; and operates various platforms, including the App Store, that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. In addition, the company offers various services, such as Apple Arcade, a game subscription service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It sells and delivers third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was founded in 1977 and is headquartered in Cupertino, California.',
'EmployerIdNumber': '94-2404110',
'Exchange': 'NASDAQ',
'FiscalYearEnd': 'September',
'FullTimeEmployees': 147000,
'GicGroup': 'Technology Hardware & Equipment',
'GicIndustry': 'Technology Hardware, Storage & Peripherals',
'GicSector': 'Information Technology',
'GicSubIndustry': 'Technology Hardware, Storage & Peripherals',
'HomeCategory': 'Domestic',
'IPODate': '1980-12-12',
'ISIN': 'US0378331005',
'Industry': 'Consumer Electronics',
'InternationalDomestic': 'International/Domestic',
'IsDelisted': False,
'Listings': {'0': {'Code': '0R2V', 'Exchange': 'LSE', 'Name': '0R2V'},
'1': {'Code': 'AAPL', 'Exchange': 'BA', 'Name': 'Apple Inc. CEDEAR'},
'2': {'Code': 'AAPL34', 'Exchange': 'SA', 'Name': 'Apple Inc'}},
'LogoURL': '/img/logos/US/aapl.png',
'Name': 'Apple Inc',
'Officers': {'0': {'Name': 'Mr. Timothy D. Cook',
'Title': 'CEO & Director',
'YearBorn': '1961'},
'1': {'Name': 'Mr. Luca Maestri',
'Title': 'CFO & Sr. VP',
'YearBorn': '1964'},
'2': {'Name': 'Mr. Jeffrey E. Williams',
'Title': 'Chief Operating Officer',
'YearBorn': '1964'},
'3': {'Name': 'Ms. Katherine L. Adams',
'Title': 'Sr. VP, Gen. Counsel & Sec.',
'YearBorn': '1964'},
'4': {'Name': "Ms. Deirdre O'Brien",
'Title': 'Sr. VP of People & Retail',
'YearBorn': '1967'},
'5': {'Name': 'Mr. Chris Kondo',
'Title': 'Sr. Director of Corp. Accounting',
'YearBorn': 'NA'},
'6': {'Name': 'Mr. James Wilson',
'Title': 'Chief Technology Officer',
'YearBorn': 'NA'},
'7': {'Name': 'Ms. Mary Demby',
'Title': 'Chief Information Officer',
'YearBorn': 'NA'},
'8': {'Name': 'Ms. Nancy Paxton',
'Title': 'Sr. Director of Investor Relations & Treasury',
'YearBorn': 'NA'},
'9': {'Name': 'Mr. Greg Joswiak',
'Title': 'Sr. VP of Worldwide Marketing',
'YearBorn': 'NA'}},
'Phone': '408-996-1010',
'Sector': 'Technology',
'Type': 'Common Stock',
'UpdatedAt': '2021-02-25',
'WebURL': 'http://www.apple.com'}
除了两个键有嵌套值(地址/位置)外,您可以看到它基本上是平面的。当我将其转换为数据帧时,我得到:
Code Type Name Exchange CurrencyCode CurrencyName CurrencySymbol CountryName CountryISO ISIN CUSIP CIK EmployerIdNumber FiscalYearEnd IPODate InternationalDomestic Sector Industry GicSector GicGroup GicIndustry GicSubIndustry HomeCategory IsDelisted Description Address AddressData Listings Officers Phone WebURL LogoURL FullTimeEmployees UpdatedAt
Street AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... One Apple Park Way NaN NaN 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
City AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... Cupertino NaN NaN 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
State AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... CA NaN NaN 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
Country AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... United States NaN NaN 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
ZIP AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... 95014 NaN NaN 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
0 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN {'Code': '0R2V', 'Exchange': 'LSE', 'Name': '0... {'Name': 'Mr. Timothy D. Cook', 'Title': 'CEO ... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
1 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN {'Code': 'AAPL', 'Exchange': 'BA', 'Name': 'Ap... {'Name': 'Mr. Luca Maestri', 'Title': 'CFO & ... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
2 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN {'Code': 'AAPL34', 'Exchange': 'SA', 'Name': '... {'Name': 'Mr. Jeffrey E. Williams', 'Title': '... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
3 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Ms. Katherine L. Adams', 'Title': 'S... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
4 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Ms. Deirdre O'Brien', 'Title': 'Sr.... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
5 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Mr. Chris Kondo', 'Title': 'Sr. Dir... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
6 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Mr. James Wilson', 'Title': 'Chief ... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
7 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Ms. Mary Demby', 'Title': 'Chief In... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
8 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Ms. Nancy Paxton', 'Title': 'Sr. Di... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
9 AAPL Common Stock Apple Inc NASDAQ USD US Dollar $ USA US US0378331005 037833100 0000320193 94-2404110 September 1980-12-12 International/Domestic Technology Consumer Electronics Information Technology Technology Hardware & Equipment Technology Hardware, Storage & Peripherals Technology Hardware, Storage & Peripherals Domestic False Apple Inc. designs, manufactures, and markets ... One Apple Park Way, Cupertino, CA, United Stat... NaN NaN {'Name': 'Mr. Greg Joswiak', 'Title': 'Sr. VP... 408-996-1010 http://www.apple.com /img/logos/US/aapl.png 147000 2021-02-25
基本上,看起来嵌套键中的每个键都在数据帧中创建新行。这是我的密码:
import json
import requests
import pandas as pd
companyData = requests.get(url="https://eodhistoricaldata.com/api/fundamentals/AAPL.US?api_token=OeAFFmMliFG5orCUuwAKQ8l4WWFQ67YX").json()
General = pd.DataFrame.from_dict(companyData['General'])
General
在本例中,我的目标是所有内容都只是一行,任何嵌套都将在相关列中显示为json。不为嵌套json中的每个项创建新的重复行
使用
max_level
参数尝试pd.json_normalize()
相关问题 更多 >
编程相关推荐