Published
Edited
Jun 7, 2021
Insert cell
md`# Forbes 2000 list mining
## Loading of the lists
Let's load the different Forbes 2000 lists from 2013, 2015, 2017, 2018 and 2020, The oldest lists from 2013 to 2018 were taken from Kaggle. The list of 2020 is taken from the web site of Forbes.`
Insert cell
d3 = require("d3")
Insert cell
dfd = require('danfojs@0.0.15/dist/index.min.js').catch(() => {
window.dfd.Series.prototype.print = window.dfd.DataFrame.prototype.print = function() { return print(this) };
return window.dfd;
})
Insert cell
df_2013 = dfd.read_csv(await "https://raw.githubusercontent.com/alogean/corpedia/master/Forbes_2000_2013.csv")
Insert cell
df_2015 = dfd.read_csv(await "https://raw.githubusercontent.com/alogean/corpedia/master/Forbes_2000_2015.csv")
Insert cell
df_2017 = dfd.read_csv(await "https://raw.githubusercontent.com/alogean/corpedia/master/Forbes_2000_2017.csv")
Insert cell
df_2018 = dfd.read_csv(await "https://raw.githubusercontent.com/alogean/corpedia/master/Forbes_2000_2018.csv")
Insert cell
df_2020 = dfd.read_csv(await "https://raw.githubusercontent.com/alogean/corpedia/master/Forbes_2000_2020.csv")
Insert cell
function print(df) {
const {col_types, series, columns, index, values} = df;
const table = html`
<div style="overflow: auto; max-height: 300px;">
<table class="df-table">
<thead>
<tr>
<th></th>
${series
? html`<th class="${col_types[0]}">${columns}</th>`
: columns.map((name, i) => html`<th class="${col_types[i]}">${name}</th>`)}
</tr>
</thead>
<tbody>
${values.map((row, i) => html`
<tr>
<th>${index[i]}</th>
${series
? html`<td class="${col_types[0]}">${row}</td>`
: row.map((v, j) => html`<td class="${col_types[j]}">${v}</td>`)}
</tr>
`)}
</tbody>
</table>
</div>
<style>
table.df-table { white-space: pre; }
table.df-table th, td { padding: 2px 5px; font-variant-numeric: tabular-nums; }
table.df-table .float32, .int32 { text-align: right; }
</style>
`;
table.value = df;
return table;
}
Insert cell
df_2013.sort_values({by: "rank", inplace: true})
Insert cell
df_2015.sort_values({by: "rank", inplace: true})
Insert cell
df_2017.sort_values({by: "rank", inplace: true})
Insert cell
function addConstantValue(df, name, value) {
let asize = df.shape[0];
let new_column = Array(asize);
for (let i = 0; i < asize; i++)
new_column[i] = value;
df.addColumn({ "column": name, "value": new_column })
}
Insert cell
addConstantValue(df_2013, "forbes_2013", "2013")
Insert cell
df_2013.print()
Insert cell
df_2015.print()
Insert cell
df_2017.print()
Insert cell
df_2018.print()
Insert cell
df_2020.print()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more