Public
Edited
Dec 2, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rawdata = FileAttachment("NetFlix.csv").csv()
Insert cell
Insert cell
Insert cell
data2 = {
const dataZ = rawdata.filter(d => (d.type === "Movie") && (d.release_year >= 2000))
.flatMap(item => {
// Extract month name from the date_added using JavaScript Date object
const dateParts = item.date_added.split('-');
const monthString = dateParts[1];
const monthNumber = new Date(`${monthString} 1, 2022`).getMonth() + 1;

// Split the country string into an array
const countryArray = item.country.split(', ').map(country => country.trim());

// Create a new row for each country
return countryArray.map(country => ({...item, country: country, monthName: monthString, monthNumber: monthNumber}));
});

return dataZ;
}//Your data operations here
Insert cell
Insert cell
data3 = {
// Transform the 'country' values
const dataZ = data2.map(function (item) {
const validCountries = ['United States', 'United Kingdom', 'India'];
const country = validCountries.includes(item.country) ? item.country : 'Others';
return { ...item, country: country};
})
return dataZ
}
Insert cell
Insert cell
Insert cell
Plot.plot({
color: { legend: true },
marks: [
Plot.barX(
data2,
Plot.groupY(
{ x: "count" },
{ x: "show_id", y: "release_year", fill: "country", tip: true , sort: {y: "y", reverse: true, limit: 10}}
)
),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
Plot.plot({
color: { legend: true },
marks: [
Plot.barX(
data3,
Plot.groupY(
{ x: "count" },
{ x: "showid", y: "release_year", fill: "country", tip: true }
)
),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
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