This week, I read and heard nonstop discussion of Nvidia, Jensen Huang, the AI ecosystem, the Trump administration, Chinese spies, and more. All this came in the wake of Jensen Huang's resignation from running Nvidia, the massive chipmaker at the center of the AI world.
And when Nvidia announced their quarterly results on Tuesday evening, it was clear that despite all of the legal, security, and personal chaos, the company continues to be extremely profitable (https://www.nytimes.com/live/2026/11/17/technology/nvidia-earnings-stock-price?unlocked_article_code=1.RVE.M6EN.5f-eJAPzBG8P&smid=url-share).
This week, we'll look at some data about Nvidia to better understand the company that has been in the news, and to see just how quickly they've grown.
Data and five questions
This week's data comes from the Securities and Exchange Commission, the American government's regulator of public companies. Official SEC data about NVidia is provided here:
https://data.sec.gov/api/xbrl/companyfacts/CIK0001045810.json
The file is in JSON, containing data from XBRL (https://en.wikipedia.org/wiki/XBRL). I originally thought that I would need to use a separate PyPI package to download SEC data, but now realize that I can use variations on that same URL to get information about other companies.
Paid subscribers, both to Bamboo Weekly and to my LernerPython+data membership program (https://LernerPython.com) get all of the questions and answers, as well as downloadable data files, downloadable versions of my notebooks, one-click access to my notebooks, and invitations to monthly office hours.
Learning goals for this week include retrieving via APIs, joins, cleaning data, dates and times, grouping, and plotting with Plotly.
Here are my solutions and explanations for this week's five questions:
Download the SEC's data for Nvida. Create a data frame from the data under facts, ecd, PeoActuallyPaidCompAmt (i.e., how much was the CEO paid), and units. Convert start and end to datetime values. Draw a bar plot showing how much Huang was paid in each of the years in the report.
First, I loaded not just Pandas and Plotly (my usual tools), but also requests, the popular HTTP client library for Python:
import pandas as pd
from plotly import express as px
import requestsThe Pandas read_* methods all accept a URL in a string, allowing them to retrieve a file from the Internet. However, many sites – including the SEC, it seems — doesn't want programs to retrieve documents from their site, so they restrict access.
However, they can't really restrict access, because browsers are programs, too. So I decided to retrieve the data using the PyPI requests package, asking it to pass a User-agent header that won't cause it to be banned from the SEC's site. I then invoked the json method, which returns Python data structures from a string containing JSON:
nvidia_url = 'https://data.sec.gov/api/xbrl/companyfacts/CIK0001045810.json'
headers = {
'User-Agent': 'BambooWeekly-DataFetch/1.0 (https://bambooweekly.com; reuven@lerner.co.il)'
}
json_content = requests.get(nvidia_url, headers=headers).json()Now what? I would normally expect that I could create a new data frame based on the Python data structures we got. That's because we usually get the equivalent of a list of dicts from JSON, which is easy to translate.
But that's not quite the case here; we have data in a fairly convoluted format, with dictionaries inside of dictionaries inside of dictionaries.
Fortunately, I only wanted you to retrieve from a particular key:
json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])This returns a dictionary. But as you might know, you can invoke pd.DataFrame on a dict and get back a new data frame:
(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
)I then wanted to add two new columns, start and end. Actually, these aren't new column so much as replacements, converting the original textual start and end to datetime columns using pd.to_datetime, using pd.col to retrieve individual columns:
(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.assign(start = pd.col('start').pipe(pd.to_datetime),
end= pd.col('end').pipe(pd.to_datetime))
)Finally, with the data largely in place, I can now invoke pipe and px.bar to create a bar plot:
(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.assign(start = pd.col('start').pipe(pd.to_datetime),
end= pd.col('end').pipe(pd.to_datetime))
.pipe(px.bar, x='start', y='val')
)The above code works, but it's a bit excessive. We don't really need the end value. In fact, we don't need any of the columns other than start (the index) and val (the compensation). I thus changed the query to be:
(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.select('val',
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
.pipe(px.bar, barmode='group')
)Notice that I've used the select method, new in Pandas 3.1. I called it with one positional argument (val) and one keyword argument. The latter works like the assign method we've used for a while. I find this to be cleaner and easier to understand, especially for anyone who has used SQL's select statement.
Meanwhile, the plot looks like this:

We can see that Huang's total compensation was quite high in the last few years, with the exception of January 2022, when it was much lower. Remember that "total compensation" includes not only salary, but also stock and options.
We'll soon look at Nvidia's stock price, but I went to Google Finance and plotted it since the company went public:

First: Wow, we can see that Nvidia's stock took off massively in just the last few years, corresponding to some degree with the crypto boom, and then even more with the AI boom. That said, we can see a significant dip in 2022, which I'm assuming is significantly correlated with Huang's compensation in that year.
From the same data set, create a separate data frame for how much the non-CEOs (NonPeoNeoAvgCompActuallyPaidAmt) were paid, on average, during the same period. In each pay period, how similar was the CEO's salary to the others? Create a bar plot allowing you to compare the two.
Using almost the same query (just changing the column name), I was able to get the mean non-CEO compensation at Nvidia:
(
pd
.DataFrame(json_content['facts']['ecd']['NonPeoNeoAvgCompActuallyPaidAmt']['units']['USD'])
.assign(start = pd.col('start').pipe(pd.to_datetime),
end= pd.col('end').pipe(pd.to_datetime))
.pipe(px.bar, x='start', y='val')
)
The plot:

At first glance, it looks remarkably similar to the CEO compensation. But then, if you look at the scale on the y axis, you'll notice that the numbers aren't quite the same. And Huang's compensation was for one person, while this plot reflects the mean of the other executives.
We can make the difference starker by combining the two data frames using join:
(
pd
.DataFrame(json_content['facts']['ecd']['NonPeoNeoAvgCompActuallyPaidAmt']['units']['USD'])
.select(val_non_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
).join(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.select(val_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
)
Remember that join works when the two data frames have a shared axis, resulting in a new data frame whose axis reflects the input data frames:
start val_non_peo val_peo
2021-02-01 38453071 105543768
2022-01-31 -1364661 -4118947
2023-01-30 85558057 234132305
2024-01-29 125583913 344188027
2025-01-27 57721552 162180936
Again, we can see that Huang's CEO salary was dramatically higher. We can even use pct_change to calculate how much better:
(
pd
.DataFrame(json_content['facts']['ecd']['NonPeoNeoAvgCompActuallyPaidAmt']['units']['USD'])
.select(val_non_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
).join(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.select(val_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
).pct_change(axis='columns').round(2)['val_peo']
The result:
start val_peo
2021-02-01 1.74
2022-01-31 2.02
2023-01-30 1.74
2024-01-29 1.74
2025-01-27 1.81
In other words, Huang was typically making roughly twice what other executives were earning in total compensation.
We can see this visually by taking our joined data frame and creating a bar plot:
(
pd
.DataFrame(json_content['facts']['ecd']['NonPeoNeoAvgCompActuallyPaidAmt']['units']['USD'])
.select(val_non_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
).join(
pd
.DataFrame(json_content['facts']['ecd']['PeoActuallyPaidCompAmt']['units']['USD'])
.select(val_peo = pd.col('val'),
start = pd.col('start').pipe(pd.to_datetime))
.set_index('start')
).pipe(px.bar, barmode='group')
The result, with Huang's salary in red:
