Free YouTube Transcribe

Video transcript

How I Use Claude Code as a Data Analyst (10 Real Use Cases)

Ryan & Matt Data Science · 10,502 words · 48 min read

Want to search this transcript, jump the video from any line, or download it as TXT, SRT, or VTT?

Open in the transcript tool

Full transcript

Intro: Why Claude Code is changing the data analyst role

0:00Data analyst role is changing. The

0:02analyst pulling ahead aren't the ones

0:04spending more time at learning a sequel

0:05or Python. They are the ones that are

0:07using AI to do in 5 minutes what used to

0:10take a 5 hours. I've been in this space

0:13for years and I've never seen a tool

0:14change how much I actually work as fast

0:16as Claude Code did. And in this video,

0:19I'll show you exactly why. 10 real

0:21workflows from cleaning up messy data to

0:23building internal tools. And by the very

0:26end, you'll see why this is the skill

0:27gap that is opening up right now in the

0:29data space. So, we're going to start off

#1: Data Cleanup (fixing messy CSVs automatically)

0:32with probably the easiest use case and

0:34this is going to be data clean up. Every

0:36single analyst is going to have a

0:37version of this file. You get a CSV from

0:40someone in your company that's data

0:41illiterate and it is just a complete

0:45mess. There's tons of issues with it and

0:47you're like, why did you send me this

0:50file? You couldn't clean it up? Uh for

0:52example, if you look at order date, we

0:54have multiple date formats. 01, okay,

0:56cool. Then we start 2024, then we start

0:58with January. Like, what are we doing

1:00over here? Then we go into something

1:02like region, New York capitalized, not

1:05capitalized. Then we have a blank region

1:06over here. Then we have different things

1:09over here like a a repeated customer or

1:11duplicated rows or missing data. It's

1:14This is just not good. In fact, there's

1:16seven distinct issues

1:18with this particular file that we're

1:20going to want to to

1:21clean up. So, I want to send this over

1:24to Claude Code and see if it can solve

1:26the issue. Typically real scenario,

1:28either you're going to go and clean this

1:30up manually in Google Sheets or Excel or

1:32you're going to write some Python code

1:34to go out there and really fix up this

1:36file. You're going to go back and forth

1:38and hey, do we actually need this row or

1:40not?

1:41And even before we do any analysis, it

1:44turns out to be 1, 2, 3 hours. Now,

1:46obviously this file over here super

1:48simplistic. We're looking at 30 rows.

1:50Real scenario, you're going to be

1:51working with something that has hundreds

1:53if not thousands or tens of thousands or

1:55hundreds of thousands of data points,

1:57but I want to show you how powerful

2:00Claude is and all I'm going to do is

2:02just describe in plain English what I

2:04particularly want it to do. So,

2:07I'm going to close out of Google Sheets

2:09over here and you don't need to load

2:11this spreadsheet up in Sheets if you

2:13want. Uh you could actually just go in

2:15load this in Excel as well. Does not

2:17matter.

2:18So, I'm going to close out of Google

2:19Sheets and then I'll load up Claude

2:21Code. Now, the version of Claude Code

2:23I'm using is directly in VS Code. Uh for

2:26each of their demo examples, I'm just

2:28going to load up the folder with our

2:30data points that we particularly want to

2:32take a look at or whatever file

2:34and I'm going to use Claude Code over

2:36here on the side. So, this isn't going

2:39to be a tutorial on how to set up Claude

2:41Code in VS Code. If you guys want to see

2:44that, I'm happy to make it that

2:46tutorial. Uh just the assumption is you

2:48have Claude Code readily available to

2:51go. All right. So, what I'm going to go

2:53over here is say, "I have a messy sales

2:57CSV that I need to clean up and analyze.

2:59The file is messy sales data.csv", which

3:02you guys can see that is over here.

3:05And obviously, if you're if you're

3:07looking at other stuff, yes, I already

3:08have the prompt written and I already

3:10have my notes for the section.

3:12And what I'm going to say is, "Please

3:13load it and tell me everything that's

3:15wrong with it. Fix all the issues you

3:16find, save a clean version, and give me

3:19a summary of total revenue by region by

3:21sales rep." So, let's grab this prompt.

3:24I'm just going to throw it over here.

3:28And uh

3:30you can see

3:32it's the exact thing I've already said.

3:35I'm going to make sure that ask before

3:36any edits

3:39as my specific mode.

3:41And then I'm just going to run this over

3:42here. So, just click on this.

3:45I should probably move myself out of the

3:46way so you guys can see that and uh

3:49we'll run it.

3:50And I'm not going to narrate over every

3:52single time that it goes through, but

3:53you can see that it's thinking, it's

3:55going through. It also found seven

3:58issues as I addressed, and it says allow

4:01right over here. That's fine. I'm going

4:03to say yes,

4:05and it looks like it's done. It took me

4:07probably about I'd say a minute or two.

4:12So, what you can see, I have my initial

4:14prompt over here.

4:16Then it's reading in the file. Then it

4:18says, "Here's what I found. Let me write

4:19a Python to fix everything." So, the

4:21issues that it found, number one,

4:23heading white space, customer name

4:25trailing space, order date leading

4:26space, which obviously was hard to see

4:28in Google Sheets, but uh it found that

4:30over here.

4:31Inconsistent casings on names, region,

4:33sales, randomly all caps.

4:36Three different date formats.

4:39Revenue as currency.

4:42Missing values.

4:44Confirmed duplicate rows and region

4:47inconsistencies.

4:49So, then it went through over here.

4:51It started cleaning up our issues. So,

4:54you can take a look at all the

4:55individual steps.

4:58Everything looks clean. Here's the full

4:59rundown.

5:01You can see

5:02revenue as currency strings. We have our

5:04revenue summary as well, which, you

5:06know, we asked it to clean up our data.

5:08So, load it in, save all the fix all the

5:10issues you find, save a clean version,

5:12and then give me a summary. You can see

5:14we have a clean version over here, which

5:16I'm going to load up in Google Sheets

5:17here for a second with you guys.

5:20But then we have the revenue by region.

5:21So, we have Southeast, Midwest, West

5:24Coast, Northeast, New York, and then by

5:27sales rep, each of the sales reps as

5:29well over here. And then it says, "Note,

5:31row 1027 has no sales rep assigned, and

5:34rows 1009 and 1021 have missing revenue.

5:36Those amounts are excluded from the

5:38totals above."

5:39I do love that note as well. I mean,

5:41that's something you would want to give

5:43to a specific stakeholder. So, let Let

5:45load this up really quick in Sheets, and

5:47uh

5:48All right, so now we have our clean one

5:50over here. Date format

5:52all consistent across the board.

5:54Revenue, it's stripped away the dollar

5:56amounts, which maybe you want to have

5:57that in over here, but this was casted

5:59as a string, uh which makes things

6:01tough. Obviously, it did automatically

6:03convert this when I uploaded it into

6:05Google Sheets, but as it's CSV and

6:07normally it wasn't.

6:09And then you can look at capitalization,

6:10like New York, this looks good. Uh

6:12customer name, this looks good as well.

6:14Uh removed our duplicate row, and uh we

6:17still have the missing revenues, which

6:19it called out. What's really nice,

6:20obviously, is it just summed up all

6:22these different regions and as sales

6:23reps. So, you know, honestly, it

6:26wouldn't really take that long to write

6:28a line of Python Pandas to get that

6:30information or just to do some filters.

6:32You could go over here and date filter,

6:34you could go, "Hey, I'm going to create

6:35a filter. Let's look at a region of New

6:37York." So, we'll say clear all, New

6:39York. And some people would be like,

6:41"Okay, well, New York has 5,470."

6:44Well, you go back over here,

6:47already done for you. So, you don't even

6:48have to worry about that side of it. So,

6:50like, obviously, this is our first

6:52example of 10 that we're going to go

6:54through today, but already, I hope that

6:57you are seeing how valuable it is. All

7:00right, let's jump into example number

#2: Spreadsheet Analysis with Python Pandas

7:03two. So, example number two is just

7:04going to expand upon what we did a

7:06little bit earlier. This time, we're

7:08going to take a spreadsheet, and we want

7:10to find data from it. And

7:13this is something I think every analyst

7:15still do on a weekly basis, if not a

7:17daily basis. And there's a lot of

7:19different approaches, you know, you can

7:20go over and write Excel formulas, say

7:22equal sign and then filter for specific

7:25criteria. You could go the old school

7:27route,

7:28do a filter, and then just go over here

7:30and say, "Hey, I just want to find

7:31what's going on with software licenses.

7:33You know, how many units did we sell?"

7:35Highlight it. Okay, we sold 2390. Or if

7:38you're a little bit more advanced, you

7:40can use something like a Python Pandas.

7:42And personally, I've used Python Pandas

7:44over the last few years and it's saved a

7:46ton of time. But maybe Python is

7:49intimidating for you and you want to see

7:52the efficiencies. Well, Cloud Code could

7:54do all of that for you without even

7:56knowing how to write Python. Now, what I

7:59will say is you should eventually try to

8:01learn the basics of Python Pandas. It

8:02will help you out, but we can automate

8:05this. So, we're going to actually go

8:06through three different prompts with

8:09this data set. Uh we're going to do some

8:11basic aggregations. We're going to do a

8:13pivot table and then we're going to do a

8:15performance analysis. So, I'm going to

8:17go into VS Code. You can see I already

8:19have this loaded in.

8:22And what we're going to do is ask our

8:24first prompt. So,

8:26I'm going to

8:27myself from here and let's write this

8:30out.

8:31So, essentially what I'm going to say

8:35I have monthly sales CSV and you can see

8:38that's a CSV file. Group by region and

8:40show me total revenue and average deal

8:42size for each.

8:45And we're going to run that.

8:48I'll be back when it's ready. All right,

8:50it is back with these results. Probably

8:53took 2 minutes, give or take. And

8:56obviously you can see it's thinking. It

8:58read our file and you'll see it actually

9:01brought in Pandas. So, pip install

9:03Pandas and here are the results. So, we

9:06have region over here, Midwest, total

9:08revenue as well as the average deal

9:10size, Northeast, Southeast, and West

9:13Coast. And I didn't even ask for it, but

9:15it gave us key takeaways. So, it says

9:17Southeast leads in total revenue at 1.7

9:20million. West Coast has the highest

9:21average deal size, nearly 2.4 the

9:23Midwest average. Midwest lacks

9:26significantly in both metrics with

9:28608,000 less revenue than the next

9:31lowest region. The code used was a

9:33simple group by and agg with the named

9:35aggregations, the Pandas equivalent of a

9:37pivot table summary.

9:40So,

9:41obviously this wouldn't take super long

9:43to write out the Python code for it,

9:44which is why I always say to learn

9:46Python Pandas as probably early as

9:48possible within your data career.

9:50However, it was able to solve this

9:52relatively fast. Okay. So, now what I'm

9:54going to ask it to do is build out a

9:56pivot table. Again, you could solve

9:59pivot table pretty easily within Pandas

10:01or if you're using Excel or Google

10:02Sheets, but I'm going to say now create

10:04a pivot table showing each sales rep as

10:06rows and each product as columns with

10:08total revenue as values, just like I

10:10would do in Excel. So, that is the exact

10:12prompt. I'll send that over here.

10:16And uh

10:17yeah. All right, this was actually even

10:19faster.

10:20And you'll see it did all its thinking

10:22over here. It showed us exactly what it

10:24was thinking. And what we have is our

10:27pivot table. So, we asked over here,

10:30showing each sales rep as rows and each

10:31product as columns.

10:34So, we have

10:36Angela, David, James, Jennifer,

10:40Marcus,

10:42Patricia, Robert, Sarah, and our grand

10:45totals at the bottom. So, 472 across the

10:47board. And this is for consulting, then

10:50we have hardware. And then if I expand

10:52this out, this is actually way nicer.

10:55Uh I don't know why I had this so small

10:56for you guys. We're going to make this

10:58essentially full screen.

11:01Over there.

11:02And uh you can see we have hardware,

11:04software licenses, and grand total. The

11:06key function, pd.pivot_table, maps

11:08directly to Excel insert pivot table.

11:10And then it says rows index equals sales

11:12rep, columns is product values

11:14summarize. So, a few things to notice in

11:16the data, reps specialize, Angela and

11:19David are pure software license sellers,

11:21while James Wilson is hardware only. And

11:23let's see if that's the case. We go to

11:25James Wilson, and you can see hardware

11:27with no consulting, no software. And

11:30it says Angela is also the same. So,

11:33Angela is software only.

11:36Yep, David software only.

11:38So, awesome insights across the board

11:42over there. Let's actually give it a

11:43third request now, and we're going to

11:46ask what reps are below their target.

11:48So, if you go back to our spreadsheet,

11:50you can see that we have a target over

11:52here as well as the total revenue. So,

11:55you know, it's it's a very

11:57blank ask, but we're going to see what

12:00definition it actually gives us. So,

12:03I want to ask it what reps are below the

12:06target, show me that gap. And we're

12:09going to go over here and run that as

12:11well. Then we have the information. Only

12:13one sales rep is below target. By the

12:15way, this area that took like 10

12:16seconds. Uh Marcus Johnson, it says

12:18revenue 822, target 960, minus 137.

12:22Marcus only rep missing his numbers,

12:24137k short at 85%. Analysis above or

12:27below, want to see the full leaderboard

12:29with all reps. And then I should ask is

12:31this by

12:33by month and region as well, because I'm

12:36sure some of these have missed, and

12:37let's just do a quick sanity check. And

12:40you can see right over here that was

12:41Marcus in January 2024.

12:45Obviously, he did get called out across

12:47the board, but we're not seeing the

12:49individual rows.

12:51So, I just prompted it again, and

12:53sometimes it won't get everything

12:54correct. I I mean, I think it did a good

12:55job here, but I just said you didn't

12:57give me the individual rows. Also, I

12:59want to see individual months a rep

13:00missed. What if they just had one good

13:02month mask a ton of bad months? And

13:03that's possible. Let's say someone was

13:05100,000 over target in one month, um but

13:08they had four other months they were

13:09down 20,000 each. Well, in net wise,

13:12they'd be plus 20%, but they only hit

13:14target one specific month. Um so, I'm

13:17just asking if it can do some analysis

13:19based around it. So, I want to see those

13:20individual rows, and then analysis based

13:22around it. So,

13:24I'll send that over. Let's see how long

13:25it takes, and uh gave these results.

13:28Okay, so

13:30here's the full picture and we can see

13:32Marcus missed, you know, four in a row.

13:35Then we have Jennifer that missed two

13:37and then we have Patricia and we have

13:39Robert. And you can see the gap across

13:42the board. So this was zero flat. I

13:44don't know if we probably should have

13:45had zero flat as a miss. I think that's

13:48a hallucination.

13:50Um but the other ones are accurate. This

13:53is summary scorecard. Months hit one,

13:56months missed three, hit rate. So

13:58actually did get that correct. I don't

13:59know why we got to see this one over

14:01here. Just a very small bug.

14:04Obviously double check the work that is

14:06being done.

14:07Jennifer Lee two two, Patricia three

14:09one. So you can see hit rate, overall

14:11gap, and also the worst monthly. Your

14:13instinct was right to dig deeper. That

14:15grid view hides a lot.

14:17Obviously as a data analyst you should

14:18know to always poke into the data. Uh

14:21things like this should be pretty

14:23apparent.

14:24It says Marcus Johnson is in free fall.

14:26He only broke even January then missed

14:27every month after that with an

14:28accelerating gap. Jennifer Lee

14:31overall positive but each missed two

14:32four months. They're inconsistent, not

14:34safety. Both had one big miss but

14:36otherwise are solid contributors.

14:39So hopefully

14:40showed you another way to really start

14:42diving into the data. Honestly without

14:45Claude this would have taken me a little

14:46bit longer to build even something out

14:48like this. I would have had to think

14:50about it, you know, what's the hit rate

14:52across the board and do a little bit of

14:54Python code.

14:56Definitely doable but but obviously

14:58we're talking about minutes versus

14:59hours. Because it even gave us a

15:00write-up which is really nice. And

15:03obviously there's a lot that you could

15:04do with this too. You could eventually

15:05turn this into presentations or

15:07documents. Talk about some of that a

15:09little bit later on uh within this

15:11particular video. But I think we are

15:12ready to move into our next example.

15:14Here's something that's happened to

#3: Automated Data QA / Audit Before Meetings

15:15every analyst. You're about to present a

15:16report to your manager. You hit send.

15:19Five minutes into your meeting, they

15:21spot an error, a number that just

15:23doesn't make sense, a missing value or a

15:25duplicate entry, and suddenly you're

15:28scrambling. So, what if there's a way to

15:30catch any of that type of stuff before

15:32the meeting? Not just visually scanning,

15:34but actually analyzing the data for any

15:36sort of anomalies, missing values,

15:38inconsistencies. That's what we're going

15:40to do in this section. Essentially, what

15:42we're going to have is Claude Code as

15:44our second set of eyes. Within this CSV

15:47file, there's going to be six separate

15:49errors that I wanted to catch. Do want

15:51to note that this isn't just focused on

15:54CSVs. Within the Claude ecosystem, you

15:56can also have it take a look at

15:57documents as well as PowerPoint

15:59presentations. Just for ease of use

16:02within this particular video, I'm going

16:04to use a CSV file. So, let me show you

16:06what the CSV looks like.

16:08So, we have our date, we have our

16:10customer, customer name, region,

16:12product, revenue, units, sales rep, as

16:15well as margin. And uh

16:18I'll send you over that quote here in a

16:20second that we're going to send uh to

16:22Claude Code, but

16:24we have a huge outlier in this data set.

16:26Take a look at this revenue. Like, that

16:29just is giant. And that's one of the

16:32things that we want to see. Uh we also

16:34have a negative revenue value.

16:36And we have some missing values across

16:39the board.

16:40There's a duplicate customer ID, which

16:42you'll see that here in a minute.

16:44There's inconsistencies about margin

16:46percentages with regions. Uh we have a

16:48wrong quarter as well. So,

16:51I want us to catch all six of these

16:53errors. And uh

16:56Yeah, so what we have is Claude Code.

16:58I'm going to

17:00type in this prompt, and then I'll just

17:02move my uh screen away. So, that way I

17:05am not in the way.

17:06So, our prompt we have

17:09I have a Q1 revenue report that I need

17:12to present to my manager in an hour.

17:15Before I do, can you check this data for

17:17anything suspicious or wrong flag

17:19outliers, missing values, duplicates,

17:20anything that doesn't look right?

17:22Obviously, we have that spreadsheet over

17:24here called Q1 revenue report. I'm going

17:26to click send and we'll be back when

17:29it's ready.

17:32All right, it's ready. So,

17:34critical issues. Number one, it spotted

17:36that revenue outlier, $980,000.

17:39It also spotted this negative revenue.

17:42And then it spotted also a wrong date.

17:46Year-end corp date.

17:472024 12 15. December is not Q1 by any

17:50fiscal calendar.

17:52And that is the one that we wanted to

17:54take a look at.

17:56You can see

17:58have that right there. Should not be

18:00present in this data set. I guess it's

18:02kind of easy to then spot, but I'm glad

18:05that was caught.

18:07We have missing revenue,

18:09missing margin percentage over here. And

18:11then it says minor observation April

18:13date included. This data set runs

18:15through 2024 4 28. Your Q1 is January to

18:18March. Rows 33 through 43 shouldn't be

18:21here. Fiscal Q1 runs through April, it's

18:23fine. Uh three critical issues, 980K

18:26outlier, negative revenue, and December

18:28date. So, going back to my notes, 980K

18:31was caught.

18:33The negative revenue was caught. Missing

18:35values.

18:36Uh it talked about row 12. And there I

18:41believe is a few other ones with margin

18:42percentage. Let me just double check.

18:45Well, we have that over here, the

18:46missing margin percentage, so we're fine

18:48there.

18:49It did not catch anything about

18:51duplicates, though. Um there are some

18:54duplicate issues. So, I should ask on

18:57that, "Didn't you miss?" And by the way,

19:01this is me already like cherry-picking

19:02the data. I already know that there is

19:04duplicate issues.

19:05But, one of the things you'll notice the

19:07more that you use Claude is always ask

19:10it a second time or a time. Like it will

19:12not get everything correct the first

19:14time, which I think is why some people

19:16absolutely do not like AI. They're like,

19:18"It's terrible." Well, it's not terrible

19:20by any means, but you need to constantly

19:22prompt it to get the best results. So,

19:25I'm going to say, "You missed

19:29the duplicate values."

19:35Were there any other

19:41inconsistencies?

19:45My terrible spelling over there.

19:54Um we have a few other inconsistent

19:56areas over there, and then we already

19:58talked about wrong quarter dates.

20:00Cool. So, I mean, it missed duplicate

20:03values. I'm just going to ask this over

20:05here.

20:08Regardless, five of the six main issues

20:10were caught. That's pretty good.

20:12And obviously that would save us a

20:14decent amount of time.

20:15You know, even with like my code that I

20:17write for full production,

20:19I will send this into Claude just to do

20:21a double-check at the very end. Uh to

20:23tidy things up. Sometimes, you know, if

20:25I'm writing pandas code, it might not be

20:27the most efficient, so I'll have it

20:30check through that, see if I have any

20:31specific errors, and uh create

20:34something. But, we'll talk about the

20:35coding review side of it a little bit

20:37later also in this particular video. So,

20:40the pushback, it definitely took a lot

20:41longer uh this time across the board,

20:44but

20:45uh what I just want to show you,

20:47it says on duplicates what's actually

20:49there. So,

20:50talks about some duplicates over here,

20:52additional inconsistencies I should have

20:54flagged.

20:55So, that's 20% drop over 3 months, the

20:57same customer and product with no

20:59obvious volume justification. It could

21:00be an undocumented discount or pricing

21:02error. Love to see that. Row 11 unit

21:05count is also not higher, not just the

21:06revenue.

21:07Our 20 to 50 units, row 11 has 500

21:10units, 10x the next highest. Given Drake

21:12only covers one account. He appears

21:14exclusively over here.

#4: Merging Data from Multiple Sources (CRM, billing, contracts)

21:16So, yeah.

21:17Um pretty good job across the board

21:20taking a look at this data set. Let's

21:22now jump into our next example. Here's

21:25what every analyst knows, your data just

21:27doesn't live in one place. The CRM has

21:29customer contracts, billing has

21:31invoices, marketing has engagement

21:33metrics, finances is something and your

21:36boss might ask you for a customer health

21:39data set. And this has to combine all of

21:41these sources together at once. You can

21:44do this in Excel and it can be a mess.

21:46You're going to have to use a VLOOKUP,

21:47index matches, as well as a manual fuzzy

21:50matching because names aren't going to

21:51line up and it could take you hours.

21:53Even if you go through the Python route,

21:55you have to make sure things are going

21:56to line up one-to-one on your joins and

21:59you're going to still spend a decent

22:00amount of time cleaning up your data.

22:02So, I want to show you how we could do

22:04this within Applied AI Code. We're going

22:06to have three real files, CRM data,

22:08billing data, as well as marketing

22:10engagement. They all use different keys.

22:12The names aren't going to match exactly

22:14and we're going to combine them all

22:16together in just one request. So, let's

22:19jump into the files themselves.

22:21First up, we have our billing data.

22:24Invoice date,

22:25sorry, invoice ID, customer ID, invoice

22:28date, amount, status, as well as our

22:30payment date. Then we have our CRM

22:32customers. So, we have 30 different

22:34customers over here.

22:36Name, industry, account owner, start

22:38date, contract date, as well as their

22:40customer tier. And then we have

22:42marketing metrics, company name, last

22:44email open, if they attended a webinar,

22:46an NPS score, and then also last

22:48contacted. So,

22:51let's jump into code and run this

22:53through. So, I have three files, CRM

22:55data, billing data, and marketing

22:57engagement. I need to combine them into

22:58one view showing each customer's

23:00contract value, whether they have

23:01overdue invoices, and their NPS score.

23:03The marketing file uses the company name

23:05instead of customer ID, and the names

23:07aren't exactly the same. So, obviously

23:10that type of context really helps if

23:11things aren't going to be lined up

23:13one-to-one. If they were lined up

23:14one-to-one, obviously you could just

23:16write some Python code and solve that

23:18pretty easily, but this is asking us to

23:20clean up the names as well as knowing

23:22some a little bit additional context in

23:24each of these files. In a real scenario,

23:26I'd probably make this prompt a little

23:28bit longer, a little bit more thorough,

23:30but since this is just a demo for you

23:31guys, let's run it. Okay, so it took

23:33literally about a minute or so, and

23:37now it gave us the results of overdue

23:39invoices. So, you can see the customer,

23:40the contract value, the overdue amount,

23:42as well as the NPS score associated for

23:45the customers, but it didn't give me uh

23:48a spreadsheet. We do have this over

23:49here, the script save combined data.py,

23:51which is Python standard library, no

23:53external dependencies. Um I'm just going

23:56to ask it, "Can you build me a CSV

23:58file?"

23:59I guess I did tell it that I just want

24:00overdue stuff, so maybe I should just

24:02add it in general, but you know, it

24:04would be good to see the contract value

24:06and zero dollar amounts. And obviously

24:09we could just filter that out if we

24:10really wanted to. All right, so we have

24:12something over here called customer

24:13combined view.csv, and I'm just going to

24:15load this up in spreadsheet now, and

24:17we'll take a look.

24:19All right, so this is our spreadsheet.

24:21We'll put the camera back on over here.

24:23We have the customer ID, name, industry,

24:26account owner, tier, contract value, has

24:29overdue invoices with the yes or no,

24:30which we could just easily filter. We

24:32could just go data

24:34create a filter,

24:35and then we'll just say yes, and you can

24:37see we have these six over here, overdue

24:39amount. We didn't have the NPS score or

24:41webinar attended for the last one, and

24:43then we had the last email, as well as

24:45last contact date. Literally just

24:47minutes instead of hours for this build.

#5: Contact Data Standardization & Regex Cleanup

24:50So,

24:51now let's jump into our next example.

24:53We've got messy data with phone numbers

24:55in five different formats. You know,

24:57regex could literally solve this in 2

25:00minutes. We also know that regex is

25:02annoying to write and you'll at least

25:04spend 30 minutes to an hour debugging

25:07and Googling, "Hey, should I include

25:08that parentheses or not?" And you just

25:11don't do it. Instead, you go through

25:13this spreadsheet, you find and replace,

25:15and do it manually. Today, we're going

25:18to be fixing that with Claude Code.

25:20We're going to go actually go through

25:21three different data points we're going

25:23to clean up. Let me show you the

25:25spreadsheet and then we'll jump right

25:26in.

25:27Okay. So, what we have over here is a

25:30full name column, which honestly doesn't

25:31really matter that much. Then we have

25:33this phone number. This is ideally what

25:35we're going to clean up because these

25:37phone numbers, they're all over the

25:39place.

25:40We also have different company names.

25:41You can see like LLC versus LLC, Inc. uh

25:45for incorporated. We're going to clean

25:47that up. And then lastly, within our

25:49notes over here, we sometimes have the

25:51budget for these companies, but

25:54it's in the text and to extract that

25:57out. Those are our three goals. We're

25:59going to actually write a prompt to do

26:00that. And uh let me jump into code.

26:03Okay.

26:05Away goes the webcam. We're going to

26:06scroll this over here.

26:09Now, I've already written this prompt.

26:10So,

26:12I'm just going to tweak it maybe a

26:14little bit, but I'll read this out for

26:16you guys.

26:17And maybe we'll expand this out. So, I

26:19have a CSV file with messy contact data.

26:23And let me actually grab the exact name.

26:27It is raw contacts.

26:30Let me throw that over here.

26:32Raw.

26:33Should be able to pick it up. That's

26:34fine. The phone number column has

26:36different formats, so I just put some of

26:37the formats over here. I need them all

26:39standardized to this. So, specify the

26:41exact format.

26:42By the notes column in raw contacts CSV,

26:45notes column contains revenue

26:47information in different formats.

26:48Extract all the dollar amounts and

26:49create a new column called estimated

26:51deal value with just numeric values.

26:53Multiple amounts found, take the largest

26:54one. If no amount found, use null. The

26:56company column has inconsistent

26:58formatting. I created a script that

27:01removes all punctuation, title cases,

27:05and removes the trailing punctuation

27:07extra spaces.

27:09Okay.

27:10I see that over here.

27:13Let's see. Update

27:16the column

27:17with the clean information.

27:22And then lastly, I say once

27:24these are fixed, save it as clean raw

27:26contacts.csv.

27:28I should say as a new

27:31file called So, you get the point. Like

27:33I

27:34give it examples. Like this is the bad

27:36data. This is how I want to see the

27:38format.

27:39This is the type of data we'll see in

27:41this column. What do I want to extract

27:42out? Edge cases as well. And lastly,

27:45again, more examples of what's

27:46happening. You know, remove all

27:48punctuation, title case, remove trailing

27:50punctuation.

27:52Gives that example. And I just want to

27:53create a new spreadsheet. So,

27:55uh very painstakingly

27:58I had to write out regex on here.

28:00And I'd rather just clean it. Okay. So,

28:02run it. And once it's done, we'll be

28:04back. Okay. So, it took about 10 minutes

28:06and we're back. So, first our phone

28:09numbers, well, these have standardized

28:11format. So, I think that looks pretty

28:13good. Uh the next we were taking a look

28:15at the company. You can see LLC has been

28:17fixed.

28:20So, that's been pretty good.

28:22We fixed the spacing on stuff.

28:25Now, this is all lower case.

28:27You can see global solutions.

28:31LLC is combined.

28:35So, this looks a lot better as well.

28:38And lastly, estimated deal value, you

28:41know, 45K, we got that. 120,000, 120.

28:45And we were able to extract all this.

28:48As it was going, obviously it was giving

28:50us Python code

28:52directly over here.

28:53And you can see we actually have our

28:55Python code saved.

28:57So you can see pandas and import RE,

29:00regular expression.

29:02And this one turned out to be a lot more

29:05code than I initially thought it was

29:06going to be, but that's okay. About 140

29:09lines that was developed, but uh

29:11we have this spreadsheet again. We need

29:13to clean it up anytime we just can run

29:15that code. So

29:17pretty awesome.

29:18I hate writing regex. I think regex is

29:21super powerful. Um but ever since I've

29:23been using just AI in general, I have

29:26not written regex by hand. I just send

29:28it over to an LLM, say what I want to

29:30extract, and it saves a ton of time. So

29:36let's jump into our next section. SQL

29:38can have a special kind of frustration.

29:40Your query runs perfectly, there's zero

#6: SQL Query Debugging (finding & fixing broken queries)

29:43syntax errors, no exceptions, but it

29:45gives you the wrong answers. You've got

29:47a revenue report that says you made

29:48three times more than you actually did,

29:50your customer ranking is grouping

29:52everyone together instead of by tier, or

29:54your month-over-month growth is just

29:56jumping around randomly. Your query runs

29:59though, it's not broken, it just gives

30:01you the wrong answer. And sometimes

30:04debugging that is not really fun. So in

30:07this section we're going to cover is the

30:09first part of this, which is debugging

30:11these queries to finding and

30:12understanding specific logic errors

30:14within SQL. And the second part is going

30:17to be optimization, because even if you

30:19write a query that runs, doesn't 100%

30:22mean it is fully optimized. It might

30:24take 5, 10 minutes to run, and reality

30:27if you work that query over again, you

30:29might be able to get it down under 30

30:31seconds. So in addition to just fixing

30:34our code, I'm also going to have a

30:35Claude explain what happened in our

30:38specific queries, so that way we can

30:40turn this frustration into a learning

30:42moment. Okay. So, we have three files

30:45for this section. First, we have our

30:47schema SQL. So, this is an e-commerce

30:50database schema

30:51looking at PostgreSQL. Obviously,

30:53there's different flavors of SQL out

30:55there, but this is what we use for this

30:56video. So, we have a customers table,

30:59products table, sales reps, orders, and

31:02then order items.

31:04Then we have sample data for each of

31:06these over here.

31:08Then we have our broken queries. So, we

31:11have multiple broken queries all

31:12together. Maybe you will only want run

31:15one query at a time in a real scenario,

31:18but I just want to show you that it can

31:19handle multiple queries. So, maybe you

31:21put in multiple at a time either way.

31:23So, we have our first one over here.

31:26Our second one, as well as our third

31:29one. In addition, we have a second

31:30section which is a slow query. So, this

31:33query works, but takes 4 minutes to run.

31:35I need it faster.

31:36And

31:37take a look at that over there. Okay.

31:39So, let me close these out.

31:44And we're going to start off with our

31:46first prompt, which is going to be

31:47fixing the queries. So, let me copy over

31:52our prompt, and then I will read through

31:54that. I'm also just going to get out of

31:55the way.

31:57So, that way we can fully see this.

31:59Okay.

32:00So,

32:02I have three SQL queries that are giving

32:04me wrong results. The schema is in

32:05schema SQL, and I have sample data

32:07loaded. Here are the queries in the

32:09broken queries, and I talk a little bit

32:11about each of the queries. For each one,

32:13identify the bug, ex- explain Oops.

32:17Explain why it's producing the wrong

32:18results, provide the corrected query. If

32:20you can, show what buggy output was

32:22versus what it should be. Getting your

32:23head around is why each bug happened,

32:25not just getting it to run correctly. I

32:27think a lot of people go out there just

32:28slam SQL code or Python code into Cloud,

32:31get the right answer, and they never

32:32learn anything. So, it's really

32:34important that you understand where your

32:35mistakes are.

32:37And we'll run this. All right, and

32:39honestly this was one of the fastest

32:40ones today, probably like

32:4245 seconds to solve these.

32:45Now obviously these are very basic SQL

32:46queries in comparison to what happens in

32:48the real world and in real scenarios

32:51sometimes you're going to have to go

32:52back and forth and prompt this in

32:53multiple times. Again, this is just a

32:55video. So, query one revenue by region

32:58fan out from unnecessary join. The bug

33:00the query joins orders order items but

33:03order total amount already stores the

33:04full order. Each order gets duplicated

33:06once per item.

33:08Why this happens is it tells us why this

33:10exactly happens.

33:12Buggy versus correct results.

33:15And you can see our corrected query. It

33:17says drop the join entirely, it was

33:18never needed.

33:21Query number two was with the window

33:22function missing partition by. The rank

33:24has no partition by so it ranks all

33:26customers globally instead of resetting

33:27the rank within each tier.

33:29So, why it happens

33:32creates a single global window

33:34and we need the partition by.

33:37We have the corrected code which you can

33:39see the partition by is in over here.

33:42And then it says add partition by over

33:44the over clause. And then query three

33:46month-over-month growth wrong order by

33:47and lag.

33:50Again, why it happens specifically

33:53it has the buggy versus the correct

33:55results.

33:56And then our corrected query down below.

33:58And then it says summary the three bug

34:00patterns and then we have all this

34:02information. Fantastic. Obviously we

34:05would want to test this out as well just

34:07to make sure this specifically works.

34:09But I'm just going to assume it works

#7: SQL Optimization & Rewriting

34:11for this particular video.

34:12All right, our second one we're going to

34:14do performance optimization and

34:16rewriting.

34:18So, we can clear out of this chat or we

34:19can keep going forward.

34:21And we're just going to keep going

34:23forward.

34:25I'm going to write this out.

34:28So,

34:30our prompt is I have a query in slow

34:31query SQL that returns the right data,

34:33but it takes 4 plus minutes to execute.

34:35There's definitely something wrong with

34:36how it's written. Analyze the query tell

34:38me what's making it slow. Rewrite to

34:39make it much faster. Find the

34:41optimization if you can estimate how

34:42much faster new version should be. The

34:44query selects customers with specific

34:45criteria filters. Help me understand why

34:47it's slow and how to make it more

34:48efficient. Uh this goes back to my first

34:51job when I was writing queries as a tax

34:54data analyst. And some of the queries

34:56that I had to rewrite from our engineers

34:58were terrible. They were just doing

34:59select stars. But I assume this error is

35:01going to be much more than a select

35:03star. We're going to run it and to see

35:05what happens.

35:06All right, a little bit longer on this

35:07one,

35:08uh but it went through over here and was

35:11able to fix it. So, let's take a look at

35:13what happened.

35:15So, four anti-patterns.

35:17Correlated subquery with nested scalar

35:20subquery inside exists, the main killer.

35:22So, it talks about this over here. The

35:24exists correlated subquery runs once per

35:26customer inside it. The scalar subquery

35:28that the optimizer may re-execute every

35:30row.

35:31At this scale, a cubic blow-up. This

35:34alone explains 4 plus minutes. Not in

35:36with a subquery problem is not in cannot

35:38short-circuit. It must compare every

35:39candidate against full subquery.

35:42Redundant distinct in all three

35:43subqueries. Self-referencing subquery in

35:46the same table. The rewrite

35:51super clean code, in my personal

35:52opinion.

35:54But this says, wait, the region filter

35:55needs a cleaner expression. The original

35:58over here. Let me rewrite that. So, it

36:00self-corrected.

36:02Then we have optimization strategy.

36:04Original, rewritten, why it's faster,

36:07speed estimate. So, conservative

36:10estimate 20 to 50 times faster on a real

36:13production data set. Wow.

36:17And uh

36:18assuming that this is all correct. We We

36:21don't know. We haven't tested out the

36:22exact code. But it was able to go and

36:25specifically rewrite it. So,

36:28whether you need to rewrite code or you

36:30need to look for specific errors,

36:33Claude is pretty good at it and it will

36:35give you learning opportunities to kind

36:37of grow out your skills. And yeah, so

36:39that's two ways we can review our code.

36:41We talked about the specific errors. We

36:43sent it to the Claude code. It told us

36:44what was wrong and gave us some

36:46feedback. And then also kind of speeding

36:48up opportunities. So, this code just

36:51took forever to run and identified some

#8: Converting Hardcoded Queries into SQL Views

36:53of the bottlenecks and was able to

36:55resolve it for us.

36:57So, this next section is kind of a

36:58throwback to my first data analytics job

37:01because one of my first projects that I

37:03had to do was convert hardcoded queries

37:07into views.

37:09The person or the team before me ended

37:11up having a bunch of SQL queries and

37:14they worked, but they were all

37:16specifically in our reporting layer. And

37:18that's just not the best approach to

37:20have, you know, 30, 40, 50 lines of SQL

37:23code in a report. You should just have a

37:25select specific columns from a view.

37:28And then you manage your view

37:30outside of that specific reporting

37:31layer. So, it was my goal to take all

37:34those queries, extract them out, write a

37:36view, and then replace the view, and

37:38make sure that report works. So, what I

37:41want to do today with you guys is build

37:43out some views with the help of Claude

37:46code. So, in this essence,

37:50we're going to slightly change up things

37:52and let me show you over here. Okay. So,

37:56we have three different reoccurring

37:57queries

37:59and maybe these are in a reporting

38:00layer, maybe these are queries that a

38:02data analyst runs every single week I

38:05just to get some updates about the

38:07company.

38:08And obviously you could just

38:09copy and paste this query, you could

38:11change up specific dates, but it is much

38:14more efficient to turn these into views

38:16and just be done with them. So,

38:19and that is what we're going to do. I'm

38:21going to go over into our cloud code.

38:23I'm going to remove my head and we're

38:25going to turn these specifically into

38:27views. So, here's our prompt.

38:32I'm going to grab this. It's a little

38:33bit of a lengthier one.

38:36So, I'm saying I have three SQL queries

38:38I run every Monday morning. We have

38:40weekly active users, revenue versus

38:41target customer health score. The

38:43queries work, but they're messy.

38:45So, they talked about issues on the

38:46quality, which we've already covered

38:48kind of in the last session, but it's

38:49good to rebuild upon it. I'm asking,

38:51"Can you convert each query into a clean

38:53SQL view, replace hard-coded dates with

38:54dynamic ones with current date and date

38:56functions?" Man, there's so many times

38:59that I've taken a look at incorrect

39:00queries and people just put hard-coded

39:02dates. It's it's terrible. If you're a

39:04data analyst and you're relatively new,

39:06please do not do that.

39:07Um

39:08move repeated logic into the view

39:10definition once, add comments

39:12explaining, and then make sure the views

39:14are named clearly. The goal I should

39:16want to select star from weekly active

39:17users on any Monday and get the right

39:19data automatically. And also tell me

39:21what these queries before and after. So,

39:23pretty straightforward.

39:25We'll run that and uh we're back.

39:28All right, that actually wasn't too bad.

39:29It took about 2 minutes.

39:31And uh super manual task in the past, I

39:33can tell you that. Uh but regardless,

39:36we have query one weekly active users

39:38problem.

39:42Replace both over here runs once,

39:44meaning today minus 7 days.

39:46Query two.

39:49Fix and then query three.

39:54Structural fix across all three.

39:57When you do this on any Monday, I'll

39:59compute it at once.

40:01But I don't see these queries in over

40:04here also,

40:06unless it just fixed it in that file.

40:08Oh, I see where the queries are right

40:09now. So, we have this view over here.

40:15It says run anything over here, create

40:17or views. So we have weekly active

40:19users.

40:20Our first view,

40:22revenue versus target,

40:24and then our customer health.

40:27And we have all of our information over

40:29here correctly formatted. So, obviously

40:32we can expand upon this and talk a

40:34little bit more within the section, but

40:36you get the point. Very good at writing

40:38SQL code. All right, let's move into our

#9: Code Documentation & Refactoring

40:40eighth example.

40:41This section addresses one of the least

40:43fun but most critical tasks that

40:45analysts have, and that is going to be

40:47documenting things. Now, personally I

40:50work in the compliance space, so when we

40:53work with regulators, it is super

40:54important that every query is

40:56documented, all of our database is up to

40:59date. But, if you're outside of

41:01compliance or like risk and

41:03underwriting, sometimes people get a

41:05little bit lazy, and that's not really

41:07helpful, especially as you bring on new

41:10members to your team or people leave.

41:12It's really important that you have some

41:14sort of documentation, otherwise people

41:16are going to become lost and hours are

41:18spent. So, we're going to take a look at

41:20two different things. Uh the first one

41:21is going to be undocumented code. You

41:23can think of this as like a script

41:24written months ago that has no comments

41:26and variable names that mean nothing.

41:28The second one is undocumented schemas.

41:31So, database tables with cryptic column

41:33names that require reverse engineering.

41:36Cloud Code can solve both of these

41:37situations automatically, transforming

41:40messy code into clear, maintainable

41:42documentation and building data

41:43dictionaries from just raw schemas. So,

41:46we're going to go through two different

41:47prompts and jump into that.

41:50Okay. So, I've already uh removed my

41:52head because I don't want to get in the

41:54way. Uh but you can see we have like the

41:56schema dump over here.

41:58And then we also have this Python

42:00script,

42:01which really means nothing. We have no

42:03comments, nothing across the board. It's

42:04pretty bad. So, we're going to go and

42:07fix both of those. So, our first one is

42:09going to be the Python script

42:11documentation.

42:13And here is our query.

42:15So, it says I wrote this Python script a

42:17few months ago and honestly I don't

42:19remember exactly it does. Can you and it

42:21says read through it and explain in

42:22plain English what it does, rename all

42:24the variables to descriptive, add proper

42:26comments, write a comprehensive

42:28docstring at the top. The script should

42:29be production-ready when you are done.

42:32And maybe I want to put our exact script

42:34over here, which is called undocumented

42:36script.py.

42:38It's Python script.

42:41Undocumented

42:44script.py.

42:46Cool.

42:47And let's run that. All right, and it's

42:49ready to go. Here's what the script does

42:51in plain English. So, it tells us the

42:53steps 1 through 6. A few issues I'm

42:55fixing as part of making it

42:57production-ready. So, it's actually

42:58fixing some of our code as well.

43:01Here's a summary of the changes made.

43:02So, plain English explanation, variables

43:05being renamed,

43:07bug fixes,

43:09and let's take a look at our

43:10undocumented script. So,

43:13we move this over.

43:17You guys can see over here now, we have

43:19our top section, which was not here

43:21initially.

43:23And then,

43:25query one,

43:27query two,

43:29a lot of notes

43:31re-labeled.

43:32And overall, I think this is a way

43:34better experience. Again, I'm just

43:36glossing through this,

43:38but if you are doing this at a company,

43:41you'd obviously want to double-check it.

43:42You would want to rewrite some stuff and

43:44rework it, but

43:46I think this is okay for this demo.

43:49Also, every company has their own style

43:51guides. So, maybe you would want to

43:52build out a style guide associated with

43:54it on what needs to be documented or

43:56what not.

43:58Outside the scope of this particular

43:59video, just kind of showing you we can

44:01document this. Okay, let's jump into our

44:04second prompt now. I'm just going to

44:07make this full screen.

44:08And our second one is going to be the

44:09data dictionary. So, I'll get out of the

44:11way for you guys.

44:13And

44:14let's write that out.

44:18Cool. So, I also have a database dump an

44:21engineer gave me and it has a bunch of

44:22tables with cryptic column names. Can

44:24you build a data dictionary with

44:25markdown table with these columns? Make

44:27reasonable inferences about what type of

44:29cryptic columns mean based off the names

44:31and the tables that they're in. Assume

44:32this is a SaaS analytics database.

44:36And we'll be back when it's ready. Okay.

44:38And uh we're done. So, I wrote a

44:40dictionary which will cover this in a

44:42second. It talks about the columns. So,

44:45decoded over here for each of these

44:47columns. So, you can see cost,

44:48acquisition source,

44:51monthly recurring revenue, a standard

44:53SaaS metric, subscription tier pricing.

44:56Few things worth noting, like an

44:58engineer, days of week in dim dates has

45:00no documented convention,

45:03no document scale at the schema,

45:05ambiguous whether this is pre or post

45:06discount. And if we jump into our data

45:09dictionary

45:11and scroll this all the way over,

45:16this looks pretty good.

45:19So,

45:21very great job

45:24documenting

45:26database as well as that particular

45:29Python query.

45:31So, this section, what we're going to do

45:32is create a mock-up dashboard. Now, in

45:36the real world, we're probably going to

45:37store all your dashboards in like a

45:39Power BI or a Tableau or a Metabase or

45:42whatever BI reporting layer you that you

45:44want, but sometimes you're going to have

45:46data in a spreadsheet and you need to

#10: Building Dashboards & Streamlit Apps

45:48just throw something together really

45:49fast and Cloud Code can essentially

45:52build us out a HTML dashboard within

45:55minutes, something that would take hours

45:57to build in another platform. So, let me

46:00show you the spreadsheet we're going to

46:02use and then let's build this out

46:03together.

46:04So, very similar

46:08very similar data that we've been

46:09covering so far throughout this video.

46:11Month, region, product, revenue, new

46:13customers, churn customers, support

46:15tickets, NPS score, ad spend, as well as

46:18a sales rep counts. And let's jump into

46:22Cloud Code.

46:24And we'll get out of your guys' way.

46:25And let's expand that out. Cool. So,

46:28here is

46:30our query we're going to write.

46:35I have a dashboard data CSV with 2 years

46:37of monthly business metrics across four

46:39regions and three product line. Build me

46:40HTML dashboard with the following

46:41visualizations: revenue trend, new

46:44versus churn, NPS score over time,

46:46summary scorecard.

46:47I make it look professional, something I

46:49could show my leadership team, use a

46:50clean color scheme, responsive layout,

46:52make it something I can open in any

46:54browser. Now, obviously, you can define

46:57colors, you could add in a lot more

46:58details over here, but for demo

47:00purposes, let's give it a shot.

47:03All right, it says our dashboard is

47:05ready to go. This took me

47:084 minutes,

47:09give or take.

47:11And

47:12we'll take a look at that here in a

47:13second. We have total revenue, new

47:14customers, average NPS, three charts,

47:17notable story in the data dashboard

47:18visible at the top of our cell, strong

47:20growth through mid-2024 followed by a

47:22concerning reversal.

47:23And let's take a look at what this looks

47:25like.

47:26Okay. So, this is our dashboard. Again,

47:28you can change all the different colors,

47:29you can make this look way nicer as you

47:33want.

47:34And uh we have our total revenue, new

47:36customers, churn rate, NPS score. I

47:38think overall, I think this looks very

47:40clean.

47:41Uh we have revenue by region. You can

47:43see we can highlight this.

47:48North America, Europe, Asia, Latin

47:50America.

47:52New churn customers, you can see

47:55we're gaining a lot of new customers,

47:57but churn is also increasing quite a

47:59bit. Then we have NPS score over time,

48:02which went up, flatlined, and then it

48:04really went down. Now, obviously,

48:07over here, this points to a pretty clear

48:09picture, but not always the case in

48:12real-world data. So, that is an HTML

48:15dashboard design,

48:18and uh next section we're going to cover

48:20Streamlit, and I will see you there.

48:23So, for section number 10, we're going

48:24to be covering something called

48:26Streamlit. Streamlit's honestly one of

48:27my favorite Python libraries, and it

48:29allows us to quickly generate data apps

48:32that we could share with our teams. At

48:34my last job, I built 15 different data

48:36apps that probably saved like anywhere

48:38from 30 to 40 hours every single week,

48:40and that stopped from other people in my

48:43team asking me, "Hey, can you help me

48:44clean up this spreadsheet, or can you

48:46combine these spreadsheets together and

48:49throw this together, or hey, I have this

48:50external data source, can you help me

48:52plot all of this data?" I would just

48:54build them Streamlit apps, and then

48:56teach them how to use Streamlit just

48:57dragging and dropping in a spreadsheet,

48:59and people were self-sufficient. So,

49:02I think it's a very powerful skill for

49:04you to pick up as a data analyst,

49:05especially if you know the basics of

49:07Python. Really spend some time with

49:09Streamlit. Let me just show you the

49:10website really fast as well.

49:12And obviously, this is not a Streamlit

49:14tutorial. I just kind of want to show

49:17you that this is out there. So, faster

49:18way to build and share data apps, and

49:21you can take a look at the gallery and

49:23different things like people build out.

49:25So, you can see dashboard designs,

49:27which is great. You can see overviews.

49:31Um

49:32a lot of people will build out some

49:34stuff around machine learning also with

49:36Streamlit,

49:38and data science.

49:40You can see this is like a Streamlit

49:41cheat sheet that someone built out. But

49:43these are just like very quick web apps,

49:45and I would say like this is a step

49:46above the HTML ones, because you need to

49:48host these. Uh Uh can host them free in

49:51Streamlit Cloud, or you could host them

49:53privately. Uh so, like if you have a AWS

49:56instance, your data engineering team can

49:57help you set up all to host these

49:59internally.

50:01There's also ways uh to host this if you

50:03have like a Snowflake subscription.

50:05Again, not the purpose of the video

50:06isn't fully to demonstrate everything

50:09about Streamlit and how it works. Just

50:11showing you that you can build out quick

50:12data apps with Python with Streamlit,

50:15and it really should replace those HTML

50:17dashboards, which I just showed you in

50:18that last section. In addition, this is

50:21really good if you want to combine

50:22multiple data sources. Like imagine you

50:24have a data source in your database, you

50:26have an external data source from a

50:28vendor, and then you have like a third

50:29data source somewhere else in a

50:31spreadsheet, and you have to constantly

50:32combine them together. Uh you can build

50:35out a Streamlit tool to do so. Okay.

50:38So, what we're going to do is build out

50:40a Streamlit app for this over here.

50:43And this is just another spreadsheet,

50:45and maybe we just get questions over and

50:47over again from our internal team. So,

50:50we want to automate this and build out a

50:52streamlit.py file. So,

50:55I have our data over here, and let me

50:58just walk you through these prompts

51:00really fast.

51:01So, we have two different prompts.

51:05And I will walk you through this. Cool.

51:07So, the first one it says, "I have a

51:08customer CSV with customer information

51:10from all accounts. My team is constantly

51:12asking me to look up customer details.

51:14Instead of being the bottleneck, I want

51:15them to

51:16build a Streamlit app where they can

51:18search,

51:19filter, have a full table view, make it

51:21professional. My sales team should be

51:23able to use it immediately. Save it as

51:26this Python file."

51:28Again, you're going to have to host this

51:29Python file. It's only going to be

51:31available locally, but I will show you

51:33really fast how we can deploy this

51:35within Streamlit Cloud. So, we're going

51:37to run this, and we have our results

51:40over here. So, customer lookup.py ready,

51:43run it over here. I'm not going to run

51:44this now. I'm actually going to deploy

51:46this in GitHub and just show you how to

51:47do that really fast.

51:49But, I'm also going to ask for a second

51:51section of this.

51:53And let's imagine we've re-prompted this

51:55again.

51:56As I mentioned, you're going to

51:57constantly want to re-prompt. So, I'm

51:59going to say, "Great, the team loves it,

52:00but now I want to add a second tab that

52:02shows management insights. Add a

52:04dashboard tab to the app that displays

52:05metrics, total customers, total

52:07contract, and then some charts, and make

52:10it visually distinct."

52:14So, we're going to upload that over

52:15here.

52:20And also, while that loads up,

52:22just to show you,

52:24we have this over here. Now, I'm on a

52:27relatively new computer, so I haven't

52:30installed Streamlit on this one as of

52:32yet. I need to still install a bunch of

52:34different Python libraries.

52:36But, you can see that we have our

52:38imports here at the top. We have a page

52:40config, which is helpful on there.

52:43We have caching, which is a typical

52:45issue people have with Streamlit.

52:47And we have this whole Streamlit code

52:50over here.

52:51All right. I'm just going to keep

52:53allowing it to update this in real time.

52:57And we have different tabs as well.

52:59Just based off of, you know, the

53:00conversation we're having right now.

53:03I'm going to keep letting it update our

53:04code.

53:06Looks pretty nice across the board.

53:08You have our tab over here as well. And

53:10you know, in the past, I had to write

53:12all this out manually.

53:16In fact, we have like a 4-hour Python

53:18Streamlit course here on the channel.

53:21And you know, there's a lot of benefits

53:22if you want to learn the basics, but a

53:24lot of this is now automated. Okay. So,

53:29it's

53:31should be good to go.

53:33I'm going to close this out, and you can

53:35see it generated all of this code

53:38for us, about 300 lines.

53:41And sometimes these Streamlit

53:43codes can be a little bit longer.

53:44Uh you can see I also don't have Plotly

53:46on this computer. That's okay.

53:49Yeah, so we can also upload this

53:50directly into Streamlit.

53:54And make sure that you have a Streamlit

53:56account. It is free. So you can see

53:57deploying free. There is pro versions

53:59also.

54:00Uh so you can deploy with Snowflake. And

54:02you have a trial. This is just public

54:04app. So we're going to do free.

54:06I'm going to sign in.

54:10Sign in with Google.

54:12Okay. Then you go over here to the top

54:14right where it says create app.

54:16And then I'm going to say deploy a

54:18public app from GitHub.

54:21And I need to upload this into GitHub

54:22now.

54:23So I'm going to go and create a new

54:24repository.

54:27And what I'm going to call this over

54:29here is

54:30cloud

54:33code Streamlit.

54:37demo

54:40I'm just going to click create

54:41repository.

54:44And then we're going to add this into

54:45our repository. I'm just going to create

54:47our main file. I'm going to call this

54:49main.py.

54:51Like that.

54:52And I'm going to copy over our code.

54:55Obviously there's more efficient ways to

54:57upload stuff, but I just want to show

54:59you a very easy way that we could do

55:00that.

55:02We're going to commit our changes.

55:07Okay.

55:08We need to add in our other file as

55:09well. So we're going upload our

55:11spreadsheet. Let me just grab that from

55:13the folder.

55:15Great. So we have our customer data as

55:16well as our main.py.

55:18And then I'm just going to go over here

55:20and look for this.

55:22Then I go back over here. Just grab this

55:23cloud code demo.

55:25main branch

55:27We're going to grab main.py.

55:29And I'm going to deploy this.

55:32And as it deploys it's going to say your

55:34app is in the oven.

55:36And once again, this is public. So,

55:39anyone can see the code associated with

55:41it. Anyone can specifically see this

55:44specific app. So,

55:45if you have

55:48stuff out there that you don't want

55:49people to see,

55:51if you have private stuff out there that

55:52you don't want people to see, not the

55:53approach. Okay. And then I have an

55:55error. So,

55:56the reason why is you can see this

55:58import plotly, and you have to import

56:01that in with Streamlit. So, I'm just

56:03going to pause and get that in really

56:05fast. Okay. And now it's working. All I

56:07did is just add a quick

56:08requirements.text file and threw in the

56:11Python library plotly.

56:13And you can see now we have a dashboard

56:15with all of our data.

56:17And this is all obviously contingent on

56:20that spreadsheet that we've uploaded in

56:22over here,

56:23which is this customer data.

56:25And you can see our dashboard has been

56:27created.

56:31yellow, red.

56:33And then we could also go back into this

56:34customer lookup and then search by

56:36company name.

56:38So,

56:39or ID. Let's say I just want to go over

56:41here and say C002. So, we'll say C002.

56:46And we have one result.

56:48And the information associated with that

56:50specific company. Again, this literally

56:52took maybe like 5 to 10 minutes in

56:55general between just prompting and

56:57uploading this into GitHub.

56:59And now we have something that our team

57:02can just go through, search for a

57:04company, or search

57:06uh for that ID and get some specific

57:08information. Obviously, this is

57:10contingent on a hard-coded CSV file,

57:13which is not the best approach, but

57:15a very quick demo for YouTube purposes.

57:17Hopefully, this gets the wheels spinning

57:19and you're like, "Oh, I have a ton of

57:20different ideas." And yes, uh if you

57:23build this out correctly, you can have

57:24Streamlit talk to your database. Being a

57:27public app on Streamlit Cloud,

57:30do not do that. Please. That is a huge

57:32security flag. If it's privately hosted

57:34in Snowflake or AWS, go for it, but uh

57:37public like I just threw over here, do

57:39not do that. Remember, anyone can access

57:42uh your code because this has to be

57:44public

57:46for Streamlit Cloud to work if you're

57:48having it as a free deployment. So,

57:51anyone could have this.

57:52You could also just run Streamlit apps

57:55privately if you specifically want to do

Outro

57:57so, but again,

57:59two prompts, we were able to build out

58:01this customer hub, and I think this is

58:04pretty awesome. So, those are 10

58:05different ways that you can become a

58:07more efficient data analyst with the

58:09help of Cloud Code. Hopefully, you found

58:12a little bit of value in this video. If

58:14you did, make sure to subscribe it to

58:15the channel, and if you're interested in

58:17a part two, let me know down below.

58:20Honestly, I have like 20 or 30 different

58:21ideas listed in a doc, and would love to

58:24make a follow-up video. If there's a

58:26technique that you are also utilizing

58:28that I didn't cover in this video, feel

58:30free to leave it as a comment, and maybe

58:31it'll be one of those featured in that

58:33next video. All right, I'll see you guys

58:35in another one.

Recently added transcripts

Browse the whole transcript library

This transcript was generated from the captions YouTube publishes for this video. Get the transcript of any YouTube video atfreeyoutubetranscribe.com, free, unlimited, no sign-up.