这是我的第一篇文章,我还是excel的初学者!
我创建了一个python脚本,用于抓取Billboard Hip Hop / R& B Charts并将数据填充到excel电子表格中。我的数据如下:
标题是广告牌编号,艺术家姓名和歌曲标题。
@resp = JSON.parse(json).to_s
我想计算艺术家在艺术家姓名下出现的总次数,包括他们是否在歌曲中出现并且还会显示顶部制图歌曲。例如:
标题是艺术家姓名,广告牌外观和热门歌曲。
1 Drake Nice For What
2 Post Malone Featuring Ty Dolla $ign Psycho
3 Drake God's Plan
4 Post Malone Better Now
5 Post Malone Featuring 21 Savage Rockstar
6 BlocBoy JB Featuring Drake Look Alive
7 Post Malone Paranoid
8 Lil Dicky Featuring Chris Brown Freaky Friday
9 Post Malone Rich & Sad
10 Post Malone Featuring Swae Lee Spoil My Night
11 Post Malone Featuring Nicki Minaj Ball For Me
12 Migos Featuring Drake Walk It Talk It
13 Post Malone Featuring G-Eazy & YG Same Bitches
14 Cardi B| Bad Bunny & J Balvin I Like It
15 Post Malone Zack And Codeine
16 Post Malone Over Now
17 Cardi B Be Careful
18 Post Malone Takin' Shots
19 The Weeknd & Kendrick Lamar Pray For Me
20 Rich The Kid Plug Walk
21 The Weeknd Call Out My Name
22 Bruno Mars & Cardi B Finesse
23 Post Malone Candy Paint
24 Ella Mai Boo'd Up
25 Rae Sremmurd & Juicy J Powerglide
26 Post Malone 92 Explorer
27 J. Cole ATM
28 J. Cole KOD
29 Post Malone Otherside
30 Post Malone Blame It On Me
31 J. Cole Kevin's Heart
32 Kendrick Lamar & SZA All The Stars
33 Nicki Minaj Chun-Li
34 Lil Pump Esskeetit
35 Migos Stir Fry
36 Famous Dex Japan
37 Post Malone Sugar Wraith
38 Cardi B Featuring Migos Drip
39 XXXTENTACION Sad!
40 Jay Rock| Kendrick Lamar| Future & James Blake King's Dead
41 Rich The Kid Featuring Kendrick Lamar New Freezer
42 Logic & Marshmello Everyday
43 J. Cole Motiv8
44 YoungBoy Never Broke Again Outside Today
45 Post Malone Jonestown (Interlude)
46 Cardi B Featuring 21 Savage Bartier Cardi
47 YoungBoy Never Broke Again Overdose
48 J. Cole 1985 (Intro To The Fall Off)
49 J. Cole Photograph
50 Khalid| Ty Dolla $ign & 6LACK OTW
我怎样才能做到这一点?
答案 0 :(得分:0)
答案 1 :(得分:0)
首先,您需要执行所谓的数据清理,以获取广告牌上的艺术家列表。
要获取唯一艺术家的列表,请将数据列表复制到电子表格中的新空间。然后选择所有数据并运行"删除重复项"功能(在“数据”选项卡下)选择艺术家列。这将为您提供所有独特艺术家的列表,并为您提供他们的热门歌曲。
现在所有那些以Y艺术家为特色的X"名字"将是独一无二的,因此您需要将其过滤掉一些。搜索"特色"带有Find函数的链接器单词,并结合Left函数使用它来仅获取第一个艺术家。像这样,var timeInterval = 5;
var blinkTime = 1;
var open_signal = 'top_left';
$(document).ready(function () {
$('#div_top_left .timer').html(timeInterval);
$('#div_top_right .timer').html(timeInterval);
$('#div_bottom_right .timer').html(timeInterval * 2);
$('#div_bottom_left .timer').html(timeInterval * 3);
$('#div_top_left .green').css('background-color', 'green');
$('#div_top_right .red').css('background-color', 'red');
$('#div_bottom_right .red').css('background-color', 'red');
$('#div_bottom_left .red').css('background-color', 'red');
setInterval(function () {
manageSignals();
}, 1000);
});
function manageSignals() {
var top_left_time = parseInt($('#div_top_left .timer').html()) - 1;
var top_right_time = parseInt($('#div_top_right .timer').html()) - 1;
var bottom_left_time = parseInt($('#div_bottom_left .timer').html()) - 1;
var bottom_right_time = parseInt($('#div_bottom_right .timer').html()) - 1;
if (top_left_time == -1 && open_signal == 'top_left') open_signal = 'top_right';
else if (top_right_time == -1 && open_signal == 'top_right') open_signal = 'bottom_right';
else if (bottom_right_time == -1 && open_signal == 'bottom_right') open_signal = 'bottom_left';
else if (bottom_left_time == -1 && open_signal == 'bottom_left') open_signal = 'top_left';
if (top_left_time == -1) {
if (open_signal == 'top_right') {
top_left_time = (timeInterval * 3) - 1;
$('#div_top_left .red').css('background-color', 'red');
$('#div_top_left .yellow').css('background-color', 'white');
$('#div_top_left .green').css('background-color', 'white');
}
else if (open_signal == 'top_left') {
top_left_time = timeInterval - 1;
$('#div_top_left .red').css('background-color', 'white');
$('#div_top_left .yellow').css('background-color', 'white');
$('#div_top_left .green').css('background-color', 'green');
}
}
if (top_right_time == -1) {
if (open_signal == 'bottom_right') {
top_right_time = (timeInterval * 3) - 1;
$('#div_top_right .red').css('background-color', 'red');
$('#div_top_right .yellow').css('background-color', 'white');
$('#div_top_right .green').css('background-color', 'white');
}
else if (open_signal == 'top_right') {
top_right_time = timeInterval - 1;
$('#div_top_right .red').css('background-color', 'white');
$('#div_top_right .yellow').css('background-color', 'white');
$('#div_top_right .green').css('background-color', 'green');
}
}
if (bottom_right_time == -1) {
if (open_signal == 'bottom_left') {
bottom_right_time = (timeInterval * 3) - 1;
$('#div_bottom_right .red').css('background-color', 'red');
$('#div_bottom_right .yellow').css('background-color', 'white');
$('#div_bottom_right .green').css('background-color', 'white');
}
else if (open_signal == 'bottom_right') {
bottom_right_time = timeInterval - 1;
$('#div_bottom_right .red').css('background-color', 'white');
$('#div_bottom_right .yellow').css('background-color', 'white');
$('#div_bottom_right .green').css('background-color', 'green');
}
}
if (bottom_left_time == -1) {
if (open_signal == 'top_left') {
bottom_left_time = (timeInterval * 3) - 1;
$('#div_bottom_left .red').css('background-color', 'red');
$('#div_bottom_left .yellow').css('background-color', 'white');
$('#div_bottom_left .green').css('background-color', 'white');
}
else if (open_signal == 'bottom_left') {
bottom_left_time = timeInterval - 1;
$('#div_bottom_left .red').css('background-color', 'white');
$('#div_bottom_left .yellow').css('background-color', 'white');
$('#div_bottom_left .green').css('background-color', 'green');
}
}
if (top_left_time == blinkTime && open_signal == 'top_left') {
$('#div_top_left .yellow').css('background-color', 'yellow');
$('#div_top_left .green').css('background-color', 'white');
}
if (top_right_time == blinkTime && open_signal == 'top_right') {
$('#div_top_right .yellow').css('background-color', 'yellow');
$('#div_top_right .green').css('background-color', 'white');
}
if (bottom_left_time == blinkTime && open_signal == 'bottom_left') {
$('#div_bottom_left .yellow').css('background-color', 'yellow');
$('#div_bottom_left .green').css('background-color', 'white');
}
if (bottom_right_time == blinkTime && open_signal == 'bottom_right') {
$('#div_bottom_right .yellow').css('background-color', 'yellow');
$('#div_bottom_right .green').css('background-color', 'white');
}
$('#div_top_left .timer').html(top_left_time);
$('#div_top_right .timer').html(top_right_time);
$('#div_bottom_left .timer').html(bottom_left_time);
$('#div_bottom_right .timer').html(bottom_right_time);
}
此函数使用iferror函数来传递不具有"特征"的名称。字。然后在结果列上做同样的事情&和|这将为您提供一个非常干净的单一艺术家名单。
要获得特色艺术家,请使用Right函数而不是Left函数执行类似的操作。
在获得干净清单后,独特的艺术家会再次过滤以将其压缩。从那里你可以使用你的vlookup或查找函数来开始计数。
答案 2 :(得分:0)
您可以使用Power Query(获取和转换数据)来操作您的表格:
let
Source = Excel.CurrentWorkbook(){[Name="tbInput"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(
Source,
{{"Billboard Number", Int64.Type},
{"Artist Name", type text},
{"Song Title", type text}}),
#"Split Column by Delimiters" = Table.ExpandListColumn(
Table.TransformColumns(
#"Changed Type",
{{"Artist Name", Splitter.SplitTextByAnyDelimiter({"Featuring","|","&"}, QuoteStyle.None),
let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}),
"Artist Name"),
#"Trimmed Text" = Table.TransformColumns(
#"Split Column by Delimiters",
{{"Artist Name", Text.Trim, type text}}),
#"Artist Highest Position" = Table.Group(
#"Trimmed Text",
{"Artist Name"},
{{"Highest Position", each List.Min([Billboard Number]),
type number}}),
#"Merge 1" = Table.NestedJoin(
#"Artist Highest Position",
{"Artist Name", "Highest Position"},
#"Trimmed Text",
{"Artist Name", "Billboard Number"},
"Merged",
JoinKind.LeftOuter),
#"Highest Song" = Table.ExpandTableColumn(
#"Merge 1", "Merged", {"Song Title"}, {"Song Title"}),
#"Artist Count" = Table.Group(
#"Trimmed Text",
{"Artist Name"},
{{"Count", each Table.RowCount(_), type number}}),
#"Merge 2" = Table.NestedJoin(
#"Artist Count",
{"Artist Name"},
#"Highest Song",
{"Artist Name"},
"Merged",
JoinKind.LeftOuter),
#"Expanded Merged" = Table.ExpandTableColumn(
#"Merge 2", "Merged", {"Song Title"}, {"Song Title"}),
#"Sorted Rows" = Table.Sort(#"Expanded Merged",{{"Count", Order.Descending}})
in
#"Sorted Rows"
给出了输出: