Latest / Talk Python To Me / #288: 10 tips to move from Excel to Python
Transcript
- 0:00Excel is one of the most used and most empowering pieces of software out there,
- 0:04but that doesn't make it a good fit for every data processing need. And when you outgrow Excel,
- 0:09a really good option for that next step is Python and the data science tech stack,
- 0:14Pandas, Jupyter, and Friends. Chris Moffitt is back on Talk Python to give us
- 0:18concrete tips and tricks for moving from Excel to Python and Pandas.
- 0:23This is Talk Python To Me, episode 288, recorded September 15th, 2020.
- 0:29Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:48and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy.
- 0:53Keep up with the show and listen to past episodes at talkpython.fm,
- 0:57and follow the show on Twitter via at talkpython. This episode is sponsored by the Voyager video
- 1:02game, which is built on Python and Linode. Check out what they're both offering during their
- 1:06segments. It really helps support the show. Talk Python To Me is partially supported by our
- 1:12training courses. I got a joke for you. What's the world's most popular IDE? Excel. Funny, right?
- 1:18Except many companies really do run on Excel to the point where they would be much better off
- 1:23using clean and simple programming tools. For many, Python's data science stack would be vastly better.
- 1:29But moving from Excel to Python is a challenge. Most data science courses don't focus specifically on
- 1:35the Excel use cases. That's why we've teamed up with Chris Moffitt from Practical Business Python to
- 1:40create a course tailor-made for helping people learn just enough pandas in Jupyter to replace the
- 1:46problematic Excel usage with clean and scalable Python code. If you or your co-workers are ready to move
- 1:52beyond Excel, visit talkpython.fm/Excel, or just click the link in the show notes to learn more
- 1:58about this online course at Talk Python training. Chris, welcome back to Talk Python To Me.
- 2:03Thanks, Michael. Really excited to be back.
- 2:05Yeah, it's great to have you back. You know, back on episode 200, this is January of 2019. So coming up
- 2:14on two years ago, we did an episode together called Escaping Excel Hell with Python and Pandas. And it was,
- 2:20I got to tell you, out of upwards of 290 episodes now, well, at the time of the recording, and this
- 2:27is the sixth most popular episode ever, there must be some sort of problem with Excel that people are
- 2:33looking forward to dodge or get away from to escape.
- 2:36Yeah, I think so. I wish I could say it was all me and people wanted to hear me. But no,
- 2:40I think you're right. There's definitely some challenges with Excel that people are trying to
- 2:44get around.
- 2:45Yeah. And there are, and we're going to talk about them. I think there's some interesting
- 2:49parallels. You do this in Excel. Here's how you do that in Python. But there's also some
- 2:54interesting possibilities like, oh, I could turn this into an API, which is not too many people are
- 2:59probably using Excel as an API. But I will bet you there's a Windows machine in the cloud
- 3:04running Excel that somebody has an API focused on.
- 3:07Oh, I'm sure you're right. And I agree. I mean, I think that's one of the real powerful aspects of
- 3:12Python is your ceiling is a lot higher. You can do a lot more once you get into Python.
- 3:16Yeah.
- 3:17If you only want to use it for a little bit, that's great. But if you really want to
- 3:20take it to the next level, those options are out there for you.
- 3:23Yeah, absolutely. So let's just do a quick catch up. It's been a couple of years since you've been on
- 3:27the show. What have you been up to since then?
- 3:29Continuing to work on the blog, continuing to write articles.
- 3:33I just saw that PB Python, Practical Business Python, got ranked as the 12th most bestest
- 3:39Python blog on the internet. That's awesome.
- 3:41I saw that. Yeah, I don't know what their methodology was. But I will say they ranked,
- 3:45I think, on four or five different categories. And the one that they gave me a little bit of a lower
- 3:49rank on was the frequency of writing new content. And I think that's spot on. I wish I could write
- 3:54more. Yeah.
- 3:55But it does take time to get good content out there. And I've really enjoyed continuing to do
- 4:00that, mainly because it helps me learn and engage with the audience and learn what people want to
- 4:05hear about with the Python ecosystem.
- 4:07Yeah.
- 4:08So I've been continuing to do that. And
- 4:10Awesome.
- 4:10I actually have a new job. So that's always been exciting in a pandemic to start a new job and
- 4:18work from home full time. Like I know you're very used to.
- 4:21I am very used to it. I got lucky and got a mobile, remote friendly job about 12 years ago.
- 4:28And I've just never looked back. You know, a lot of the stuff that people are discovering in this
- 4:33pandemic has kind of been things I've embraced in life and really appreciate. I don't appreciate being
- 4:39locked away from my friends, not being able to go to restaurants. But I do appreciate not having a
- 4:43commute, not having all the expense and all those kinds of things. That's really nice.
- 4:47I definitely enjoy getting up in the morning and my commute is a couple steps from the bedroom and
- 4:52not 30 to 45 minutes. Definitely enjoy that.
- 4:56That's right. My office is in my garage, which is a separated garage in my house. I got to go across
- 5:00the sidewalk periodically. I'll scare a squirrel when I go out in the morning. So there's a chance of
- 5:04excitement, but it's pretty low excitement.
- 5:06Yes. Yes. Definitely have to find some benefits in all of this.
- 5:09That's right. So you said you have a new job. What kind of work are you doing there?
- 5:14I'm working, I'm continuing to work in the medical device industry. And right now I'm doing pricing
- 5:19strategy and analytics. So working with the company to plan our new product launches and what our pricing
- 5:25strategy is and how do we execute those effectively. So it's been really enjoyable so far.
- 5:30Yeah. It sounds like you're able to take these ideas and just a hundred percent make that the core of
- 5:35what you're doing.
- 5:35Yeah, absolutely. I mean, a lot of, you know, I keep quoting your term that Python is a superpower,
- 5:41and that's definitely the case for me is the knowledge that I have to take Python and apply
- 5:47it to some of those real world business problems that I encounter on a day-to-day basis, clean some
- 5:52data, manipulate some data, build some visualizations to tell a story. It's really powerful and I really
- 5:57enjoy getting a chance to do that.
- 5:59Yeah. I do think programming is a superpower and Python is a special kind of superpower for sure.
- 6:04Exactly.
- 6:05Now it's been, like I said, about two years since you were on the show. We did talk about some of the
- 6:10benefits of choosing basically Python's data science stack over Excel. But let's, for those who don't
- 6:19have an insanely good memory or haven't heard it before, let's just do a quick review of like some of the
- 6:24reasons you might want to use Python instead of Excel.
- 6:27Sure. So the first thing I think of is the repeatability aspect. So in Excel, once you create
- 6:34something, you'll typically end up with a bunch of tabs and a bunch of data all over the place and a
- 6:41bunch of formulas that are nested, maybe some VBA. And it's really hard to repeat that process. There's
- 6:47no way to start from the beginning and do it again. So if you've done some analysis, say,
- 6:52in January and you want to repeat it in October, you almost have to start from scratch. You can see
- 6:58that file, but there's no just button to push to run it all again. And with Python, if you do it right
- 7:03and build a script, then you do have that repeatability aspect.
- 7:06One of the things that drives me crazy about Excel from a programmer mindset is you hear of the different
- 7:13control flow structures and whatnot in programming languages like Python didn't have a switch statement,
- 7:19but maybe Python is getting a switch statement. It has obviously ifs and loops. One of the things
- 7:24very few people boast about their language having or saying a good thing is a go-to statement. You're
- 7:30like, oh, our go-tos are really improved now. Like, no, no, they're not.
- 7:33No, no. And like you said, Excel is just kind of like a whole bunch of go-to statements. And that
- 7:38really is the way you need to troubleshoot Excel. And I think that's the other piece is that
- 7:44repeatability kind of goes hand in hand with traceability. I mean, you can certainly write
- 7:48challenging Python code that's hard to understand. But in general, Python code flows from the top to
- 7:55the bottom and you can see what happens. Whereas Excel, it is really hard to figure out what's going
- 8:00on. And even if you look at the formulas, there can be errors in the formulas or there can be
- 8:05gaps in the formulas. So there's just a lot of subtle bugs that are difficult to trace with Excel
- 8:11that I think Python makes a lot easier.
- 8:13I think one of the challenges is when you look at an Excel spreadsheet or it could be Apple numbers or
- 8:19it could be Google sheets, like the same basic thing, the data is hiding the logic, right? You
- 8:26see a number in a cell and you don't know whether that number was typed there, what was imported from
- 8:31something, or if it was computed in a really complicated way. And so you've got these go-tos on
- 8:37top of like labels that hide the go-tos.
- 8:39And you can hide the data and just see the formulas, but then you don't see the data.
- 8:44So like you said, even when you try to get around it, it is not very easy at all.
- 8:49Yeah. What about lots of like large files or lots of data, something like that? Excel, Excel's at it,
- 8:56right?
- 8:57It's funny. I mean, we're certainly not talking about big data by any means, but when Excel gets
- 9:02to a little over a million rows, it just can't read the data. And nowadays it's very easy to get data
- 9:07that's well outside of what Excel can handle. And I even think if, even if you have a data set that's
- 9:14relatively large and fits in Excel, the performance penalty is pretty large and it's difficult to
- 9:20manipulate that data and analyze that data efficiently in Excel because it's just
- 9:25kind of a resource hog, right? You've got a lot of things that Excel supports, which are really nice
- 9:29from a visualization and the way it looks on screen. But in Python, for the most part, once that data is
- 9:35read in, if it fits in memory, it's going to be pretty performant and you can manipulate gigabytes
- 9:40of data on kind of your standard laptop pretty easily with Python without having to move to some
- 9:46of the more advanced data science tools.
- 9:48Yeah. I'm always, it blows my mind how fast programming languages are. Even when you've got
- 9:54slow Python, right? I think performance of Python is super interesting because you can talk about
- 10:00this code runs more slowly than say compiled C++. Maybe it's 20 times slower if it's doing numerical
- 10:06calculations, but that's still really fast. But there's also, of course, I could put that into
- 10:11like a numpy array. Now it's back to the C level speed and there's all these variations.
- 10:14But I remember on this course, I just did the memory management course. There's a section where I did
- 10:20performance around different types, structuring your classes in different ways. And so one of the metrics
- 10:26I had was how many attributes of the classes can you access per second? I think it was like 18 million
- 10:33reads per second. You're like, that's a lot of processing, right?
- 10:37Right. Right. Absolutely. And one of the things that I found is even just reading in an Excel file,
- 10:42it just takes time. Even in Python, it takes a lot of time because that Excel file is pretty bloated.
- 10:48It carries a lot of information outside of just the data. But once it's in Python, then it almost
- 10:53doesn't matter. It's really quick and a really, really big benefit.
- 10:58Yeah. The other thing to keep in mind as we're talking about this to position it is much of what
- 11:03you're proposing or you're going to propose shortly is to use Python's data science stack. So when we
- 11:09talk about the performance of data analysis in Python, what you really mean is mostly the performance
- 11:15of data analysis in C, right? Because when you talk about NumPy and pandas, a lot of that stuff is
- 11:21orchestration layers in Python over top native code.
- 11:25Sure. So people a lot smarter than me have figured out how to build these capabilities in C. You're right.
- 11:32And it also runs on Windows. It runs on Mac. It runs on all the different operating systems.
- 11:37And you're right. It runs very quickly, much more so than people would expect, especially people that think
- 11:43that Python has this reputation as being a slow language or maybe not a performant language.
- 11:48Yeah. Yeah. Meanwhile, Instagram is running on Python. YouTube is doing a million requests a second.
- 11:54Like there's variations on what defines slow, right? I think another interesting thing that is not
- 11:59mentioned here, but is probably worth mentioning is price.
- 12:04Yes, absolutely. So there are commercial variations of Python and there are companies that support Python,
- 12:13but Microsoft is making it available through the Windows store for free. All of the tools that we've
- 12:19mentioned like pandas or using conda for managing the environment are free and open source.
- 12:25So you can at least get started with it without having to buy some enterprise licensing. And when you
- 12:30get in big companies, enterprise licensing is really expensive. And I think sometimes developers that maybe
- 12:36haven't been in that environment don't realize how much companies pay for some of these licenses for
- 12:42commercial software. It's just really, really crazy to think about.
- 12:46Yeah. And I think most enterprises probably have maxed out Excel for everybody, right? They all have Word, they all have Excel, and you know, they all have Outlook.
- 12:54Right.
- 12:56But you want to do some computation, say in the cloud, right? I want to take some of this work and analyze it over there or turn it into an API endpoint or whatever.
- 13:05All of a sudden, maybe we don't have licenses to like fire up Windows machines and put Excel, like that doesn't make a lot of sense, right?
- 13:12Whereas you just take these same things as people know in Python and you just pip install them over there instead of over here.
- 13:18Or conda, you take your pick.
- 13:20Yes. And I think that speaks to this concept that there's just this higher ceiling with Python that you can get started and then, like you said, start to move to the cloud, start to move to some of these other services that are out there.
- 13:31And you can take the same thing that you're doing on your local machine to analyze a few thousand rows of data and scale it in the web to millions and millions of rows of data.
- 13:42Right. Docker, Kubernetes, all these things become an option.
- 13:45Exactly. Yes.
- 13:47Nice. A lot of what we're saying sounds like use the Python data science stack instead of Excel.
- 13:52But I know for sure there are many people who must deliver an Excel product or maybe receive input starting from an Excel worksheet, a workbook.
- 14:02And they've got to maybe they can make this step to the side where I say the rebels live, you know, but they've still got to either receive or deliver Excel, present stuff for other people in Excel and so on.
- 14:16There's some cool integration on that level as well.
- 14:19Right. Yes. And I think you're touching on a really key point.
- 14:22I think people that come from a programming background and see Excel just see the challenges.
- 14:27But businesses run on Excel and there is a lot of power in Excel and you can't just take Excel out of the organization.
- 14:35You shouldn't march into your CFO's office and say, we're deleting Excel and everybody's going to learn to use Python.
- 14:43That's just not practical in any world.
- 14:45And I don't think that will really be in the future.
- 14:48So thinking about the problem and thinking about where Python really solves the problems and where Excel can still be leveraged.
- 14:54Excel is a great modeling tool.
- 14:56Python using Pandas and some of the other tools we'll talk about allows you to export Excel files and even build interactive Excel files that you can share with others.
- 15:07So that those that just want the final answer or that final report or the final model can still do it in Excel.
- 15:14And Excel is a perfectly appropriate tool for a lot of those scenarios.
- 15:19Yeah. And there's some nice libraries that you can read Excel files.
- 15:23Obviously, Pandas just imports them directly, but you can also write to them like you can format the cells.
- 15:29You can change their colors.
- 15:30You can add formulas back into the Excel file you deliver.
- 15:34Right. So there's a way to sort of do all your work in Pandas, but then generate something that's a live Excel.
- 15:40Yes.
- 15:41Artifact for people who need to pick it up and run with it.
- 15:44I've done that quite a bit.
- 15:45And I think it's like a lot of data analysis.
- 15:47You start with a rough cut.
- 15:49And so maybe you dump something to Excel and it doesn't look very pretty, but it gives you what you need.
- 15:53And then once you get to the point where it's almost like a production ready report that you want to give to people every week or month or whenever,
- 16:02then you can start to apply that formatting and you can put all the styles that you can really do in Excel by hand.
- 16:09You can put those in.
- 16:10You can put pivot tables.
- 16:11You can put visualizations.
- 16:12There's a whole bunch of things you can do there.
- 16:15And then if you really want to take it to the next level, you can start to do some of the more sophisticated visualizations like with Streamlit or some of the other tools that are out there that really allow a high degree of interactivity on front or on top of that Python base capability.
- 16:34This portion of Talk Python To Me is sponsored by the PC game Voyager, available on Steam and published by Tollip Consulting.
- 16:40Voyager is an edutainment game in which you travel around the world.
- 16:44You visit famous cities and discover well-known landmarks and attractions.
- 16:47Enjoy stylized graphics, beautiful photos, and the local music of each city.
- 16:52You even apply for a variety of jobs to pay for your next plane ticket.
- 16:56Play it yourself or suggest it for your children so they can learn about the world instead of playing battle royales all the time.
- 17:02And for an added bonus, Voyager is written entirely in Python.
- 17:06Visit talkpython.fm/voyager or just click the link in your podcast player.
- 17:12You'll get a key for the game and instructions on how to redeem it on Steam.
- 17:16Or you can, of course, also just search for Voyager on Steam.
- 17:20That's V-O-Y-A-G-E-R directly on Steam.
- 17:23With something like Streamlit, you could publish it.
- 17:28People could consume it live.
- 17:29Yes.
- 17:30Maybe there's even a download as Excel button.
- 17:33Yeah, absolutely.
- 17:33I mean, I think there is a challenge and I think that'll be something that happens in the future is
- 17:37how do you build up that infrastructure at a company?
- 17:41When you're at a startup, maybe it's easy to spin up a service and get Streamlit going.
- 17:44But as a company grows, it's not that easy for most people to just get access to a Linux server somewhere and run Streamlit and host it for the organization.
- 17:54Even though it may be technically relatively simple, there's a lot of hoops to go through.
- 17:58So I don't think we've quite made that as easy as we'd like.
- 18:01But I think it's going to continue to improve in the future.
- 18:03Yeah, I agree.
- 18:04If you're just barely moving outside of Excel and you're just starting to pick up Python, like set up your own cloud VM with Linux and SSH probably is a bridge too far.
- 18:15Yeah.
- 18:16I mean, it's certainly gotten a lot easier than it was many, many years ago.
- 18:19I mean, there's so many services that just almost make it push button.
- 18:22But I think there's also this aspect of security as well.
- 18:26There's I think there's a lot of flexibility in being able to bring Python and install it on your system.
- 18:31And there may be some challenges with your IT organization to get that supported.
- 18:35But the one thing that I do think is really challenging is when you deal with sensitive data, you want to be careful about putting it out in the cloud.
- 18:42And those are the types of things you really get in trouble if you put all your confidential pricing data on a server somewhere and the company is not supportive of that.
- 18:50That's kind of what they call a career limiting move.
- 18:53That's right.
- 18:55You go into the big board meeting like, look, I've done all this amazing work.
- 18:59That's on the Internet.
- 19:00You're fired.
- 19:00Exactly.
- 19:01Wait a minute.
- 19:02What just happened?
- 19:03I thought I was doing good.
- 19:04I definitely don't want to promote that.
- 19:05And I think most people understand that.
- 19:07And there are certainly varying degrees.
- 19:09Some companies, it's probably wouldn't be a challenge.
- 19:12But then you go to the banking industry or the government or other places.
- 19:16And that is.
- 19:17Or the medical industry, like what you are in.
- 19:19Yeah.
- 19:19Or the medical industry.
- 19:20Yes.
- 19:21A huge, huge challenge.
- 19:22Yeah, absolutely.
- 19:23So let's dive into the 10 tips.
- 19:25Before we do, some of these tips are coming out of a course that you wrote at Talk Python.
- 19:31And you want to just tell people really quickly about the course?
- 19:33Sure.
- 19:34Sure.
- 19:35So we just went live with this course.
- 19:36And what I'm really excited about is we start from the beginning.
- 19:40And it is kind of a Windows focus.
- 19:42Because I think a lot of people that are taking this course are in a Windows environment.
- 19:45And all the code that we walk through can run on Windows or Mac or Linux.
- 19:51But I start from the beginning.
- 19:53How do you get your system set up and running in Windows?
- 19:56And then one of the powerful aspects of Pandas is that it is a complex library.
- 20:02But you really only have to learn a few concepts to get started.
- 20:06So we start from the beginning, assuming you know a little bit of Python.
- 20:09And then progress through these Pandas concepts with the idea that we want to get you up and running as quickly as possible.
- 20:16So that you can apply the code to your own business problems and start to solve some problems.
- 20:21And I use the model of talking about how you would do something in Excel and translate it to Python.
- 20:27And talk about the Pandas library commands and functions that you would use to manipulate the data.
- 20:33And then at the end, I have a kind of a real-world scenario where we talk about ingesting an Excel file or multiple Excel files, combining them, analyzing them, cleaning them, and then generating an Excel report.
- 20:46And I think this course really is a nice summary of how you can quickly get up to speed with Python and Pandas, get that stack running, and build a stable foundation for you to progress and just take on more and more complex tasks as you grow your skills.
- 21:02Yeah, it's super cool.
- 21:03I really enjoyed going through the course as just somebody consuming it, even though I helped put the pieces together.
- 21:08And there's some of my stuff I do, some accounting in Google Sheets, not actually Excel, but effectively the same experience.
- 21:16And after that, I'm like, yeah, I really need to take some notes and rewrite some of the important parts of what I'm doing in Excel.
- 21:22So yeah, people should definitely check that out.
- 21:24I'll put a link in the show notes.
- 21:26All right, without further ado, let's talk about 10 quick, easy things that we can do in Python and Pandas to move, sort of solve some of our problems or solve a series of problems in one analysis in Excel.
- 21:38Sure.
- 21:38So I think the first thing is, and it may sound obvious, but being very specific about defining the problem you want to solve.
- 21:46And so the example I'd give is if you came to me and said, hey, Chris, I'd like to build a model to predict customer churn at the company.
- 21:56And I'd say, well, what kind of model do you have today?
- 21:59And they say, well, we don't have a model.
- 22:01Well, that may be a little bit much to start out with.
- 22:04I think something more appropriate might be, here's a report where I open up Salesforce every day.
- 22:11Someone copies and pastes some data into an Excel spreadsheet.
- 22:15Someone manually cleans it up and then emails us out.
- 22:19And we do it every day.
- 22:20And it takes us 30 minutes a day.
- 22:22But we have, you know, an intern do it for us.
- 22:25That's the crazy stuff is there's somebody usually at these companies that do that.
- 22:29Yes.
- 22:30Either because they were told every day, every Monday, beginning of the month, whatever, before the presentation, like they sit down and they do these things.
- 22:38And it just, it blows my mind because, you know, you maybe spend two hours, but it's not just the two hours.
- 22:44Like what if there's a mistake?
- 22:47You know, it could be tremendous.
- 22:50One of the things you pointed out in the course was there's all these, there's like this history of crazy Excel errors.
- 22:58Right?
- 22:58Yeah.
- 22:59And I think I even mentioned one where one of the genome types that they use in scientific notation, you know, in scientific publications, they actually changed it because it was being confused with a date type in Excel.
- 23:12So essentially, it was easier to change science than it was to change Excel to properly process this data.
- 23:19That's right.
- 23:20I read that article in the global organization that oversees the naming of genes.
- 23:24Yes.
- 23:24The sequence of DNA pairs that give us all, all the different features we have.
- 23:30Some of them were named in ways that were being detected.
- 23:33Like one was March one, all one word, but that would become March 1st if you type that in.
- 23:38So they literally renamed, I think, 27 different genes.
- 23:42So they would be Excel friendly.
- 23:43They wouldn't get renamed and or reinterpreted.
- 23:47And then also they set up guidelines to say you can't name stuff that might be understood in a non-obvious way by Excel.
- 23:55It's crazy.
- 23:56It's crazy.
- 23:56I mean, as someone from a computer background, you would think, well, why would it matter what it's named?
- 24:01But we've all been bitten by those Excel trying to help you with things that just make it all the more worse.
- 24:07Yeah, exactly.
- 24:08So my disbelief or something along those lines is that this person sits down and does this every so often.
- 24:15And you only ask that question weekly, probably, because it's so painful to create the answer.
- 24:21And it's so error prone to create the answer.
- 24:23What if you could instantaneously, you know, instant, just like on demand, say, give me the current state of the report for the last seven days now or whatever.
- 24:33Right.
- 24:33And that was a five second calculation rather than a person that could make errors.
- 24:40And when it's a very manual process and it takes time, there may be things that you could do to tweak it to make it more useful.
- 24:47Maybe you want the report daily or maybe you want to add some extra fields.
- 24:50But people just don't want to take that on because it is painful.
- 24:54But once you start to automate this process, then adding a new field is easy or increasing your distribution list or reformatting it.
- 25:02Now I want a PDF version.
- 25:03Right.
- 25:03The granularity.
- 25:04Right.
- 25:05Like, well, we can't do it by zip code.
- 25:07We've got to do it by state because it's already taken half an hour.
- 25:09It would take a week.
- 25:10Right.
- 25:11We did it by zip code.
- 25:11So those kinds of things.
- 25:13All right.
- 25:13So step one or tip one is define the problem clearly.
- 25:16Yes.
- 25:17And it's not just defining it clearly, but it's making sure that you understand that problem.
- 25:22So it's almost more taking an existing problem that is really well understood.
- 25:26So you can just focus on learning Python and not learning the problem.
- 25:29And as you grow your skills, then you can start to tackle more and more complex problems with that base kind of Python knowledge.
- 25:36Yeah.
- 25:36One of the problems with all computer models, computer software is it'll almost always give you an answer whether or not that answer makes any sense.
- 25:43Exactly.
- 25:44Yes.
- 25:45Yeah.
- 25:45100%.
- 25:46All right.
- 25:48Tip number two.
- 25:48So the second one is get your Python environment set up.
- 25:52And it's gotten a lot better over the years, especially in the Windows world.
- 25:57As I mentioned, it is now officially supported in the Windows store and you can install it there.
- 26:03But I recommend using some sort of environment.
- 26:06I prefer using Miniconda to install it on Windows, install Python and the associated libraries on Windows and manage the environments.
- 26:16I think that's kind of the key thing to take some time and get it set up.
- 26:21Because one of the crazy things, just as I've taught new people how to use it, the concept of where are files on my file system is actually something you need to spend some time on.
- 26:32When you're on a Windows environment and you've got OneDrive and you've got Teams and you've got SharePoint and you've got Box and you've got Network Drive and local files, most people aren't very familiar with where they all are.
- 26:45And Windows makes it hard sometimes to even know exactly where on the disk something is.
- 26:50And that's a pretty important skill to have as you start getting your Python environment set up.
- 26:56And so it's really important to kind of get that base foundation in place so that you can start doing the actual Python development.
- 27:04Yeah.
- 27:05And there's a little bit of work to manage the concept of an environment.
- 27:08Right.
- 27:09Like that's not a trivial thing.
- 27:11And the unfortunate aspect is that hits you like step one or two.
- 27:15You know, the very next thing you basically start with is, OK, you need an environment then.
- 27:20But what's I think trickier is paths.
- 27:24Like, oh, when I type Python, it means this.
- 27:26But actually, Pip, if I type that, it means something else from a different environment.
- 27:30Like I pip installed a thing, but then I run Python and it's not in there.
- 27:35It can't import it.
- 27:36Well, it's like because for some reason, the pip was from the Python 2.7 path.
- 27:40And the Python, when you typed it, it runs the Python 3.1, which is not even the same thing.
- 27:45You know, you don't even want to get into that conversation.
- 27:48So I think it just started clearly with like content environments or something like that makes it a much easier thing.
- 27:54Once you get over that small step, then it's pretty straightforward.
- 27:56Yes.
- 27:57Yeah, absolutely.
- 27:58And I think if you confront it head on and have that discussion and encourage people that if you follow this process, you're not going to break anything.
- 28:07So if you're in a virtual environment, the worst case is your virtual environment is messed up and you can kind of restart that.
- 28:13Throw it away.
- 28:13Start over.
- 28:14Exactly.
- 28:15Yeah.
- 28:16Yeah.
- 28:16And especially on a work computer, I suspect.
- 28:17Right.
- 28:18Like I periodically will get frustrated and reformat my home computer.
- 28:22But if it's like a corporate one and it's got all sorts of VPN stuff that they're going to ask you, why are you messing with it?
- 28:29You just don't even want to mess that thing up.
- 28:31Yes.
- 28:31Maybe you don't have permissions to either.
- 28:33Yeah.
- 28:34And that is one of the things that has gotten better with Python is you can install it without administrative access, which in the past wasn't always the case.
- 28:42Yeah.
- 28:43Another thing that you advocate, and I guess this leads us into tip three, is really be super organized about your data because you can have source data, but then maybe you open up those Excel files and edit them and then they're no longer source data or they're all mixed in or they have random names.
- 28:58So what's your tip on kind of setting the stage with data?
- 29:02One of the things that I encourage people to do is get the data in as raw a format as possible.
- 29:09So what that might mean is if it's, say, a sales summary data, can you actually get transaction level data that's maybe directly from a data warehouse or your ERP system or somewhere so that it has all the information you need and is in a format that you don't touch?
- 29:27So maybe it's Excel, maybe it's CSV, but you store it somewhere and do not touch it at all.
- 29:33Because I think what people tend to do with Excel is because you can open up the data, you go in and make changes.
- 29:41So people will go and change a file name or change a cell or clean up some data by hand, which is fine, but it's not reproducible.
- 29:50Right.
- 29:51So I encourage people to set up a structure where the data is stored and you never touch it.
- 29:57And then if you do need to manipulate it, you have an intermediate directory structure where you store that manipulated file and then another directory structure where you store the output file and start getting in that disciplined process of managing those input and output files.
- 30:11Yeah.
- 30:12And you take this as far as having a cookie cutter template that people can run cookie cutter name of the template and it'll generate like the raw data file, the intermediate processing, the reports, the code, all that kind of stuff that always do it the same.
- 30:25Right.
- 30:25Yes.
- 30:26It just makes it easier.
- 30:27And when someone's starting, they don't have all the bad habits.
- 30:30Right.
- 30:31So this is just, you know, this is how you get started.
- 30:33You create these directories and you move between the directories in this way.
- 30:37And people are trying to learn so much.
- 30:40It's just accepted that that's the best way to do it.
- 30:43Yeah.
- 30:43And if you hand it off to someone else, right.
- 30:45Some people in the accounting department worked on it, then they handed it off to, I don't know, the marketing people.
- 30:51If they all know that this is the way we do it, then they understand where to go.
- 30:55And I also set it up and I encourage people to do this so that you're less likely to make a mistake.
- 31:02And if you do make a mistake, you're not going to really break the whole pipeline.
- 31:06It's kind of segmented out and firewalled almost, if you will.
- 31:10Yeah, absolutely.
- 31:11All right.
- 31:12Number four gets us into some of the pandas commands.
- 31:15Yes.
- 31:16So I love pandas.
- 31:18Pandas is a, an extremely powerful toolbox.
- 31:22And I think that is a big challenge for new users, because if you start to approach pandas, it's almost like, well, where do I start?
- 31:30How do I get a handle on all the options that are out there?
- 31:34And so I think that the first thing to do is to understand how to select your data by rows and columns.
- 31:42And pandas has the loc command, .loc, as well as the .iloc.
- 31:48And all the basic pandas tutorials kind of cover this.
- 31:53But when you're working with Excel, this is actually an extremely powerful command.
- 31:59And it can be almost deceptive how much you can get done with it and how much you need to learn it to use it in the day-to-day analysis.
- 32:06So I'd like to spend time just starting there with the basics of selecting data by rows and columns.
- 32:14So if you have a data frame, got some columns and some rows, I can say df.loc, L-O-C, bracket.
- 32:20And then you can give it column names, almost like slicing, right?
- 32:24So I could say, like, state colon country.
- 32:28And that might give me state, zip code, city, country.
- 32:31Yes.
- 32:32Yep.
- 32:33So it's kind of building up that mental model.
- 32:36People have Excel.
- 32:38They have A through ZZ columns.
- 32:41And they have the number of rows.
- 32:42And we're kind of used to manipulating data that way.
- 32:45This starts to get people to think about it in the pandas way.
- 32:50And I think it's different, but there's enough similarities that it kind of fits in that mental model.
- 32:55Yeah, for sure.
- 32:56One of the differences is now all of a sudden it's much more important what you name your column names.
- 33:01Yes, you're absolutely right.
- 33:03It matters what you name your columns, but the order doesn't matter now.
- 33:06So that's one of the challenges with Excel is, let's say you're doing a VLOOKUP and then you add an extra column in there.
- 33:14Suddenly your VLOOKUPs are broken or something else breaks down the line.
- 33:18So this is a little bit more like kind of a SQL table approach where you care about the names more so than the order.
- 33:25And I think that it's easier to troubleshoot naming changes than it is to troubleshoot order changes.
- 33:32This portion of Talk Python To Me is brought to you by Linode.
- 33:37Whether you're working on a personal project or managing your enterprise's infrastructure,
- 33:41Linode has the pricing, support, and scale that you need to take your project to the next level.
- 33:46With 11 data centers worldwide, including their newest data center in Sydney, Australia,
- 33:50enterprise-grade hardware, S3-compatible storage, and the next-generation network,
- 33:56Linode delivers the performance that you expect at a price that you don't.
- 34:00Get started on Linode today with a $20 credit and you get access to native SSD storage,
- 34:06a 40-gigabit network, industry-leading processors,
- 34:08their revamped cloud manager at cloud.linode.com,
- 34:12root access to your server, along with their newest API and a Python CLI.
- 34:16Just visit talkpython.fm/Linode when creating a new Linode account
- 34:22and you'll automatically get $20 credit for your next project.
- 34:24Oh, and one last thing.
- 34:26They're hiring.
- 34:27Go to linode.com slash careers to find out more.
- 34:30Let them know that we sent you.
- 34:31The order changes are a nightmare.
- 34:35Yes.
- 34:36So next tip is to use what are called accessors.
- 34:40Yes.
- 34:40Which are really cool.
- 34:41I had no idea about accessors before I checked out your course.
- 34:44Those people have much data frames I would actually work with.
- 34:47Well, this is another kind of good analogy to Excel.
- 34:51So we talk about selecting rows and columns of data.
- 34:53But now what do you actually do to that data?
- 34:57And the string accessor gives you a lot of powerful capability to clean data, to manipulate string data.
- 35:04So if you have text, you can uppercase it.
- 35:07You can lowercase it.
- 35:09You can strip out characters.
- 35:10You can use regular expressions.
- 35:12You can pretty much do anything that you can do in Python on a string.
- 35:16You can do in pandas.
- 35:17And the creators of pandas have done all this work to make it really fast.
- 35:22So you don't have to write loops.
- 35:24You use these accessors for strings to get at that data and potentially filter your data or clean it.
- 35:31And then the date time accessor is extremely powerful.
- 35:36I mean, I think it's one of those things that it seems on the face that it just gives you access to the date.
- 35:42But you can do so much with it.
- 35:44And it is so much easier to work with dates and times and pandas than it is Excel.
- 35:49And so I think that's a really fundamental concept to grasp so you can start to build more manipulation analysis capabilities in Python and pandas.
- 36:00Yeah.
- 36:00And that sort of hints a little bit on the underlying types.
- 36:03Yes.
- 36:04Right.
- 36:05Like Excel has some kind of idea of types a little bit.
- 36:08Like you do have the date columns and it knows about numbers.
- 36:11Put numbers on the right and strings on the left, for example, is a pretty good giveaway.
- 36:15But it's more important here because you're doing these operations.
- 36:18Like the dot DT probably doesn't make a lot of sense on a string and vice versa.
- 36:23Right.
- 36:23Yes.
- 36:24And that is one of the things where I think as people are new to pandas, there's a lot of times where pandas will make it easy for you.
- 36:32But there are certainly times where you have to go into it a little bit more and force the types and make sure that you're having good discussion or a good decision about what type you want.
- 36:41And I think it also exposes maybe errors in your data.
- 36:45So you think it's a date, time column, but then you go into it and realize you have some dummy values in there and you have to figure out at least what to do with it.
- 36:54And Excel may not care.
- 36:55But pandas is going to force you to really understand that data and make some decisions about it so you can process it appropriately.
- 37:02Yeah, that makes a lot of sense.
- 37:03Another thing that you touched on or sort of implied there is that even in regular Python programming, you do a lot of loops and things like that.
- 37:12Like I want to compare these two sets.
- 37:14So I might do a loop and then zip them together and then check whether the thing I got back, you know, they compare in some way.
- 37:20But just in pandas in general, you have to have a much more of a set based mindset, right?
- 37:26Yes.
- 37:27In general, like I don't even think in the course I even talk about loops.
- 37:33And for the most part, you should.
- 37:34Yeah, I don't think you do either at all.
- 37:36Not have to do a loop in pandas.
- 37:39Now, you may have to loop through files or something to get the data into pandas.
- 37:43But for the most part, looping is not something you want to do in pandas because they have, like you said, these vectorized formulas.
- 37:51So they're specialized and they kind of apply everything in parallel versus sequentially in a loop.
- 37:57And it's a different way of thinking.
- 37:59And it takes a little bit of time to kind of get that all there.
- 38:03But I think it is really powerful because you think about the data as a whole versus a whole bunch of individual cells in an Excel file.
- 38:10Right.
- 38:11And you could probably still just loop over everything, index back into them and update it.
- 38:15But it would not just be more verbose, maybe more error prone.
- 38:19It would also be slower.
- 38:20Yes.
- 38:21Much slower.
- 38:21Much slower.
- 38:22Yeah.
- 38:23Yeah.
- 38:23Speaking of working with sets and stuff, the next tip, Boolean indexing.
- 38:28So Boolean indexing is really combining those accessors that we talked about with location to then filter your data.
- 38:36And I think the best example I always use is like the auto filter in Excel.
- 38:40That's probably one of the most common things that I use.
- 38:44And I suspect most people use when you get a new data set.
- 38:47You open up your data and you click that auto filter and you select maybe a date range and you select maybe certain customers you're looking at or sort by revenue, whatever you're doing.
- 38:58And it's just all those kind of drop downs that you select.
- 39:01Well, essentially, the Boolean indexing or masking allows you to do that in code so that you can select those data sets and maybe do additional summary analysis or you can actually update the data set.
- 39:14So this is a powerful tool, not just for analysis, but also for cleaning your data.
- 39:18Right.
- 39:19So you could say things like if the total sales for this particular customer is greater than 100,000, I want to pull them out to a separate set and work with them special or maybe give them a discount.
- 39:30Right.
- 39:31Add to their discount range.
- 39:32Things like that.
- 39:33Absolutely.
- 39:34It's almost like anything you would do with an if statement in an Excel formula you can do with this combination, but it's much more powerful and easier to manage because it's in Python.
- 39:47It's not this kind of crazy nested Excel statement.
- 39:51And so you can build it up and as complicated as you want, but at least it's all just clean Python and not just kind of gnarly nested Excel formulas.
- 40:01Yeah.
- 40:01Whoever came up with the if statements and those kinds of things in Excel, what were they thinking?
- 40:06I don't know.
- 40:07I don't know.
- 40:07It definitely doesn't scale very well to multiple if statements.
- 40:11It's not the simplest sort of thing, right?
- 40:13No, no, it's not at all.
- 40:15No.
- 40:15All right.
- 40:15You talked about next step.
- 40:17You talked about having the data in its most raw format and I concur.
- 40:22I think that's a great idea, but that often means it might be too granular for the types of questions you're asking.
- 40:30The granularity might be off, right?
- 40:31Like maybe I want to know sales by state, but I have sales by city, every cell.
- 40:37And I just want to know the number and the state, for example.
- 40:40Right.
- 40:41So I might maybe could do a group by or something.
- 40:43Yes.
- 40:44Group by is, I think, outside of the local accessors.
- 40:49I use group by a ton.
- 40:51And group by is the way you can actually aggregate your data across multiple different columns.
- 40:58And then not just sum the data, you can perform many mathematical functions on it.
- 41:03You can do the average.
- 41:04You can do a standard deviation.
- 41:06You get the min and the max.
- 41:07But you can almost have as many levels as you want.
- 41:12And so it's very trivial to do a group by.
- 41:15And like you said, look at it maybe by state.
- 41:18And then you look at it by region.
- 41:20And then maybe you look at it by product.
- 41:22Who knows?
- 41:23Yeah.
- 41:23The salespeople or the product.
- 41:25Yeah.
- 41:25So it's just a lot of flexibility with very minimal code.
- 41:30And I find that that's a really much simpler way to analyze the data and just kind of iterate
- 41:36through that process using group by.
- 41:38And it's another one of those functions.
- 41:41It's almost deceptive in how powerful it is.
- 41:44Yeah.
- 41:44Yeah, absolutely.
- 41:45It's another one of those set based mindsets as well.
- 41:48Yes.
- 41:49Yes.
- 41:50Because it's not your the everything is kind of done on the
- 41:53column basis.
- 41:54And so it's just doing all the heavy lifting behind the scenes for you.
- 41:59Yeah.
- 41:59So next tip, when I hear people who are Excel power users, you know, they're doing serious
- 42:06stuff because they talk about pivot tables.
- 42:08I don't know.
- 42:09I do what pivot tables or of these.
- 42:11And then how do they manifest over in pandas?
- 42:13Sure.
- 42:14So you're right.
- 42:15The pivot table is kind of the I think it's probably the number one tool that people use
- 42:20in Excel.
- 42:21And it's a really convenient way to group the data in multiple different levels across
- 42:27rows and columns.
- 42:28So you can adjust how many levels you want to group it.
- 42:31And then you can summarize the numeric values in multiple different ways.
- 42:36And what is really nice about it from an Excel perspective is it's all GUI driven.
- 42:40So you can kind of drag and drop your columns and put them wherever you want so that you
- 42:44can quickly adjust the way the data is being presented just using that GUI.
- 42:49And what pandas has the pivot table command is really kind of group by on steroids.
- 42:56So everything that group by can do pivot table can do.
- 42:59And it uses the similar kind of structure that the Excel pivot table uses as well.
- 43:06And so what I find is group by is the first step.
- 43:10And then as I start to group more and more levels or do something called unstacking or stacking
- 43:16the data, then pivot table really makes that easier.
- 43:20And I think that's a nice transition for people that have experience with Excel.
- 43:23They have this pivot table concept.
- 43:25And pandas does the same thing.
- 43:27And if you start to master that, you've really got a very powerful tool to do a lot of quick
- 43:33and easy analysis and reporting.
- 43:35Yeah, absolutely.
- 43:36So another thing that you talked about is taking multiple sources of data, maybe multiple Excel
- 43:43workbooks that have some column that means the same thing and sticking those together and
- 43:49having it merge that data together automatically.
- 43:52Yes.
- 43:53So I think in Excel, probably the most common way to do that is the VLOOKUP.
- 43:58So everyone has some VLOOKUP experience.
- 44:01They're more advanced.
- 44:03Maybe they use index match, or I think there's the new Excel called XLOOKUP, which is even more
- 44:09powerful.
- 44:09But the basic idea is it's kind of a very simple merge or join of the data.
- 44:15And pandas supports that.
- 44:17But pandas merging of data is much more like the SQL approach where you can do a left join or
- 44:23right join and inner and outer joins and have a lot more sophisticated usage where you can
- 44:29join maybe on multiple columns without having to concatenate them together like you would
- 44:34in Excel.
- 44:34So it's really powerful to do that.
- 44:36And then also, I'm sure a lot of people in Excel will do just the cut and paste.
- 44:41So you've got different tabs with data, and you can easily, if the data is all the same,
- 44:47stack it on top of each other with the pandas concatenate command.
- 44:50Right.
- 44:51I've got January, February, and March's sales data.
- 44:54I want it for the quarter.
- 44:55So we're just going to jam it on the end.
- 44:57Exactly.
- 44:57One after another, right?
- 44:59Yeah.
- 44:59Yeah.
- 45:00And I think people do that all the time.
- 45:01And that's certainly a valid approach.
- 45:04It's hard to repeat, and it's easy to make mistakes.
- 45:07But once you master those concatenate and merge commands, then it's very easy.
- 45:12And things that you can do in Excel where maybe cutting and pasting, you know, a thousand
- 45:17rows is fine.
- 45:18But if you have a million, you just can't really do that in Excel.
- 45:20Whereas pandas, it's all the same command, whether you're doing 10 rows or 10 million rows.
- 45:24Yeah.
- 45:25Yeah.
- 45:25Very cool.
- 45:26All right.
- 45:27So far, these nine tips have probably given us a nice result.
- 45:31We've got the data.
- 45:32But one of the cool things I can do in Excel is I can go over to that chart section.
- 45:36They want this kind of chart or that kind of chart.
- 45:39Yes.
- 45:39Yeah.
- 45:40And so the next tip is picking a plotting library or a data visualization library and starting
- 45:46to learn it.
- 45:47So one of the challenges in the Python ecosystem is there are a lot of options.
- 45:53It's a good thing because there are a lot of options.
- 45:56There's a lot of really good options.
- 45:58But it is challenging for a new user to figure out where to start.
- 46:02So I just want to do a bar chart.
- 46:03I want to do a line chart, maybe a box plot.
- 46:06Right.
- 46:06Even just knowing what basic library I need to start researching.
- 46:10Should I do Plotly?
- 46:11Should I do Matplotlib?
- 46:13I've heard there's other things, right?
- 46:15Where do you even start, right?
- 46:16Yeah, it's really hard.
- 46:17And so what I think is important is if you're getting started and you're tackling this kind
- 46:23of well-known problem and you've built up some core pandas knowledge, pick a library
- 46:29and go with it.
- 46:30And right now, the one that I recommend, it's certainly not the only one, but I've had some
- 46:35good experience with it is Plotly.
- 46:36And specifically, Plotly has a Plotly Express API, which is kind of a streamlined approach to
- 46:43manipulate data.
- 46:45And I think that that works really well.
- 46:48One of the things I like about it is it integrates well with your Jupyter Notebooks.
- 46:52It is interactive by default.
- 46:54So once you build one, it does all the JavaScript behind the scenes.
- 46:58So you can hover over your plots and see the individual data points.
- 47:02And it works really well.
- 47:04Nice.
- 47:04And if you need to do more in-depth modifications of it, you can do that as well.
- 47:10So I think it strikes a nice balance.
- 47:12There's certainly other options out there.
- 47:14But what I think is best for someone is to pick one and stick with it a little bit and get a
- 47:20feel for the API.
- 47:21And then if you decide that that's not the right one, maybe look at some alternatives as well.
- 47:25Yeah, a lot of these have galleries, right?
- 47:28You can go into the gallery and go, does it make pictures kind of like I need yes or no?
- 47:32And then you can decide whether to pay attention to it.
- 47:34Yes.
- 47:35And I think the way these libraries plot is so different from Excel.
- 47:40It takes some time for you to kind of figure out how to fit it in your brain so that you can
- 47:46use them effectively.
- 47:47And so that's why I encourage someone to stick with it, get it, you know, apply it to your problem.
- 47:53And it even goes back to our earlier point about getting the data.
- 47:56So you have to have the data in the right format in the sufficient level of detail so that you
- 48:01can do this plotting.
- 48:02But once you get your mind around it, it's much faster to iterate through your visualizations
- 48:07and really get some meaningful insight with just very few lines of code.
- 48:12Yeah, absolutely.
- 48:13The one I've been using for this kind of stuff lately is Altair.
- 48:16It's been nice as well.
- 48:17Yeah, I like Altair as well.
- 48:18I mean, it's a great one.
- 48:19Bokeh is good as well.
- 48:21It's kind of hard.
- 48:22It's like picking your favorite child.
- 48:24You certainly don't want to go on record with that.
- 48:27But if you pick one of those three, I don't think you're going to go wrong.
- 48:30Yeah, absolutely.
- 48:31All right.
- 48:32Well, those are some really great tips.
- 48:33Like I said, after seeing all these things in action, I'm like, I've been doing it wrong.
- 48:37I've got to take some time and go and put some of this in practice and what I'm doing because
- 48:42I've got Excel type things like everyone else, you know?
- 48:45Yes.
- 48:45And you, if you're using Google Sheets or other things where you want to pull in data,
- 48:49I think that's really where you'd experience a lot of benefits.
- 48:53And those are some of the other, you know, next level benefits of using Pandas as you have those
- 48:58ability to bring in data pretty seamlessly and easily through APIs or other sources.
- 49:04Yeah.
- 49:05And it's worth also pointing out that we said you can read and write Excel files with
- 49:10Python and that's great, but you can also read and write Google Sheets, right?
- 49:15So if you need to deliver a Google Sheet to somebody or update an existing one, there are
- 49:19APIs to connect to a Google Sheet and do similar things to it.
- 49:23Right.
- 49:24And it's all pretty straightforward.
- 49:26And especially once you're using Pandas, it will either support Pandas or if it doesn't
- 49:30support Pandas, it's going to be pretty easy for you to figure out how to get that Pandas
- 49:34data into that format because Pandas is such a common tool that everybody uses.
- 49:39Yeah.
- 49:39Awesome.
- 49:40All right.
- 49:40Well, let's wrap up this tip section with a really quick thought.
- 49:44You know, you've been going through this journey at a couple of companies, probably to varying
- 49:49degrees of willingness or unwillingness with various participants in the loop.
- 49:54What's your advice to people out there?
- 49:57What's your experience been?
- 49:58I think the thing that you have going for you now is the data science kind of revolution and
- 50:05so many people understanding that data science is the thing, artificial intelligence, machine
- 50:11learning, whatever the term is like it is for better or worse, a little bit of a buzzword.
- 50:15People in your organization are going to know about it.
- 50:18And I would say leverage that to say this Python tool, which can help us with data science
- 50:23tasks, can also help us with some of these manual processes that we have.
- 50:27And you can point to maybe some of your bigger enterprise applications that actually support
- 50:34Python.
- 50:35So I'll give one example like Tableau is a visualization tool that I think a lot of companies
- 50:40have and they actually have bindings for Python.
- 50:43And if you go to a Tableau user group, they will talk about using Python.
- 50:47So it's not as foreign a concept anymore as it used to be.
- 50:50So I think in general, people are going to be more receptive to talking about Python.
- 50:55So frame it in those terms as this is kind of a data science industry standard that you want
- 51:02to start learning and applying to your specific use cases.
- 51:07And then I think the other thing I'd recommend is it is really hard.
- 51:12I think you talked about this before.
- 51:14People look at Python and Python seems so easy.
- 51:17It is kind of like pseudocode.
- 51:21And people say, okay, I understand it.
- 51:23But getting them to take the next step to actually write code for themselves to solve their own
- 51:28problem.
- 51:28So I think trying to find a way to have a cohort of people.
- 51:31Maybe you need two or three people.
- 51:33You're going down this journey together.
- 51:35So it's not just you.
- 51:36It's coworkers or maybe cross-functioning across different departments where you hold each
- 51:42other accountable to actually doing some of the work.
- 51:44So you're learning about it.
- 51:46You're applying it.
- 51:47You're using this group to reinforce it and keep the momentum versus just getting caught
- 51:54up in all the day-to-day work that squeezes out all the fun stuff you'd like to do in Python.
- 51:59Yeah, for sure.
- 52:00And one other tip I would throw in there is nothing solves the debates about whether this
- 52:06is possible, whether this is a good idea, as just doing it, right?
- 52:11So your example of we're going to spend 30 minutes to get all this data together and then
- 52:15we're going to fill it out in Excel.
- 52:16Like if you say, maybe if you're one of the high-end programmers of the company, it's not
- 52:21going to give you much credence.
- 52:23But if you're somebody who's not typically the developer and you go and say, look, this used
- 52:28to be super painful and error-prone and monthly, now I wrote this code and it took me four hours
- 52:33instead of two.
- 52:34But now I just push the button and it's instant, always, right?
- 52:37Everyone else would be like, wait a minute, that was horrible.
- 52:39We can avoid horrible things like that, right?
- 52:41Like play, I think playing to that angle as well, it's got a lot of value.
- 52:44And you have to be able to be comfortable selling those wins, letting people know that, yes,
- 52:50this is something we accomplished.
- 52:52Here's something maybe behind the scenes, some data we scrubbed or manipulated.
- 52:56And then nothing breeds success like success.
- 52:59So once you prove you could do it, people start to come to you and say, hey, you know,
- 53:04like I had some survey monkey data that I worked with to clean up and I didn't spend a lot of
- 53:11time explaining how much work it was to clean it up.
- 53:13I just did it.
- 53:14But the next time a survey came out, you know, they came back to me and said, hey, could you
- 53:18help with this?
- 53:19And fortunately, I had those scripts.
- 53:20So all that time and energy I spent there, I could just kind of repurpose and keep moving it
- 53:25forward.
- 53:25Yeah.
- 53:26Cool, cool.
- 53:27Two really quick things I just want to touch on while I've got you here.
- 53:30You put together a really nice article on setting up a Python developer environment on Windows,
- 53:37but using Linux.
- 53:38I want to tell people real quick about that.
- 53:40Sure.
- 53:41So several years ago, Microsoft came out with something called Windows Subsystem for Linux,
- 53:47WSL.
- 53:48And it's essentially gives you kind of a lightweight kernel in Windows that you can then install
- 53:57Ubuntu or a couple other different versions of Linux.
- 54:00And you've got a full Linux environment running on your Windows system.
- 54:05And it opens essentially instantaneously.
- 54:07And performance is good, but also it integrates with Windows.
- 54:12So when you want to use your file explorer to look at your files on the WSL system and copy
- 54:19between your Windows system, it's easy to do.
- 54:21You can even do things like this is really cool.
- 54:24Like you run a Jupyter Notebook in WSL and it will open up your Chrome browser in your Windows
- 54:30environment.
- 54:31So they are much more tightly integrated than just like a normal virtual machine or a dual
- 54:37boot system.
- 54:38And a lot of this is on the Windows Subsystem 2, right?
- 54:41Correct.
- 54:42If you do enough research and you look back, people might complain that it doesn't do some
- 54:46of these things.
- 54:46But that was version one before it was kind of more integrated.
- 54:50Correct.
- 54:51Yeah.
- 54:51There were some changes under the hood, especially with the file systems and the way they were
- 54:55set up and how the access is done in speed.
- 54:58So definitely anybody that's thinking about going down this path, use WSL 2.
- 55:02And the other thing that Windows has done is I don't have any specific insight, but it sounds
- 55:06like it's been very successful.
- 55:08And I know Microsoft has even backported WSL 2 to some of the prior builds so that you don't
- 55:14even have to be on the bleeding edge quite as much as you did in the past.
- 55:18So I think they've really hit on something with being able to use a full Linux system
- 55:25in Windows and using the new Windows Terminal, which, you know, it's a little surprising to
- 55:31get excited about a terminal given how long they've been around.
- 55:34No, it's not.
- 55:35It was horrible.
- 55:35But the Windows Terminal is really nice.
- 55:37And if you've worked on a Linux system, you're going to feel right at home.
- 55:42And it's really powerful.
- 55:43Yeah, absolutely.
- 55:44Now, I guess it's worth pointing out really quickly that you can do everything that you've
- 55:48been talking about up to this point without Windows subsystem for Linux.
- 55:51But it's just if you want to sometimes certain things work better on Linux and you don't have
- 55:56to go create virtual machines and stuff if you don't want to.
- 55:58Yes.
- 55:58And I will say I do think Windows subsystem for Linux, I think you need administrative access
- 56:05to get that all set up and running.
- 56:07So that may be a little more difficult for people to do on their work computers.
- 56:11But if you have a computer at home or you do have admin access, it's pretty cool.
- 56:16Yeah.
- 56:17A lot of power.
- 56:18Yeah, for sure.
- 56:19And then you have this other project called Side Table, which sounds like it makes displaying
- 56:24information exactly like an Excel user who found their way over to Pandas might want to
- 56:29do better.
- 56:29Tell us about that project real quick.
- 56:30Sure.
- 56:31It's a simple library I put together, but I've actually found it really useful.
- 56:35I use a lot of my day-to-day analysis just to get quick summary tables of my data.
- 56:42So I think probably the more correct term is it's a frequency table, but it gives you quick
- 56:48summary information if you just want to know on a new data set, like how much, how are sales
- 56:55distributed by state or by region or by salesperson.
- 56:59It's just kind of a quick one line command that will give you a nicely formatted summary
- 57:04of your data.
- 57:05It doesn't require anything else outside of Pandas, so it's easy to install and really
- 57:10streamlined and kind of integrated with your data workflow.
- 57:13And so I've really enjoyed working on that and I've enjoyed using it and hope others will
- 57:18as well.
- 57:18Yeah.
- 57:19People can just check it out.
- 57:20I'll put a link in the show notes and it's visually very clear why you'd want a better
- 57:24presentation than some of the default Pandas output as it shows up.
- 57:28And it's nice.
- 57:28Yeah.
- 57:29Cool.
- 57:29Cool.
- 57:29All right.
- 57:30Well, before you get out of here, let me ask you the final two questions.
- 57:33If you're going to write some Python code, maybe you're going to do this kind of work that you're
- 57:37talking about.
- 57:37What editor do you typically use?
- 57:39So I'm changing my answer from the last time.
- 57:41So last time I think I said I was sublime, but I am using Visual Studio Code now.
- 57:46And back to the WSL point, it integrates really well with WSL as well.
- 57:51Yeah, it does.
- 57:51It runs everywhere.
- 57:53So yeah, I really enjoy it.
- 57:55I'd say my one knock on it is I don't spend enough time in it to actually memorize all the
- 58:00shortcuts.
- 58:00So I try and force myself to get more efficient with it every time I use it.
- 58:04But I really enjoy using it.
- 58:06Yeah.
- 58:06There's a lot of stuff underneath the surface that you don't know that's there unless
- 58:09you know to go look for it.
- 58:11Yes.
- 58:11Yeah, very cool.
- 58:12And if you come from a sublime background or Atom, Visual Studio Code seems like the very
- 58:18natural like, well, here's the modern version of that thing.
- 58:20Yes.
- 58:21Yeah, it's great.
- 58:22And I do keep up with, you know, every month they give updates and they're really doing a
- 58:27lot of improvements on Jupyter Notebook support.
- 58:29And there are some pretty cool things you can do with that integration right now.
- 58:32So I'm excited to see how that evolves over time as well.
- 58:35Yeah, for sure.
- 58:36All right.
- 58:37Also notable PyPI package or Conda package.
- 58:40If you prefer to view it through that lens.
- 58:42But, you know, something cool that people maybe don't know about.
- 58:45We could pip install side table as one of them.
- 58:47That's certainly one.
- 58:48The other one I'll go back to is we talked about Plotly Express.
- 58:52There's a library called Kaleido.
- 58:55I think is how you pronounce it.
- 58:56That actually makes it easy to export your images, the graphical images you create with
- 59:02Plotly to a PNG or an SVG file.
- 59:06And I use that a ton just to generate some graphics, save them out and, you know, send
- 59:11them in an email or put them in a PowerPoint.
- 59:13And that's really high quality.
- 59:16So sometimes I've done the copy and paste.
- 59:18So you use the screen snipping.
- 59:20It's not just the screenshot or whatever.
- 59:22Yeah.
- 59:23Exactly.
- 59:24So it doesn't sound that revolutionary, but it's just one of those things that's really,
- 59:28really handy to have and really useful and it works well.
- 59:31Yeah.
- 59:31Well, people spend a lot of time looking at presentations and it just, if it has those,
- 59:37that fuzzy screenshotty feels like this isn't those kinds of things add up.
- 59:43It's like having a good microphone when you're on Zoom or something like that, right?
- 59:46Exactly.
- 59:47You're never going to get criticized for not having it, but people just like to talk to
- 59:52you more or it's a more pleasant experience if they don't have to strain to hear you.
- 59:55Yeah.
- 59:55That was a perfect analogy.
- 59:57Yeah.
- 59:57Thanks.
- 59:57All right.
- 59:58Well, final call to action.
- 59:59People, Python's popularity has grown since the last time we spoke by quite a bit.
- 1:00:04So the opportunity to use the Python data science tools are probably even more in their own
- 1:00:10now than they were then.
- 1:00:11What do you say?
- 1:00:12Yeah, absolutely.
- 1:00:13I think you kind of wonder when that curve is going to flatten out.
- 1:00:17And I still think we have a long way to go.
- 1:00:19And Python just has so much to offer to automate and improve processes where people only know Excel.
- 1:00:26So I think try and encourage people to start taking that journey.
- 1:00:31And if they're interested in the course, certainly would love to have them take the course.
- 1:00:35So I think that's a good place to get started.
- 1:00:37And I'd say maybe if you're advanced enough with Python and don't think you need the course,
- 1:00:43maybe it's a good place for your co-workers to get started as well.
- 1:00:46Yeah, absolutely.
- 1:00:47The course is great.
- 1:00:47Like I said, it inspired me.
- 1:00:48We're also doing a free webcast in a couple of weeks, which is actually a month ago.
- 1:00:54Because of time travel of podcast recording.
- 1:00:56But just another point of how much this kind of stuff is wanted, right?
- 1:01:01I sent out one email and one social media message.
- 1:01:04And over almost 1,000 people, surely by the time it's finished, 1,000 people have signed up for this webcast.
- 1:01:09Like, sign me up.
- 1:01:10I want out of this Excel thing.
- 1:01:11Yeah.
- 1:01:11No, I'm really looking forward to that.
- 1:01:13I think it's going to be great.
- 1:01:14I mean, it really was great.
- 1:01:15Yes.
- 1:01:16It was great.
- 1:01:17It went really well.
- 1:01:18I'm sure that it did.
- 1:01:19But I want to point out that it's recorded and I'll put a link in the show notes.
- 1:01:22So whatever it is that Chris and I come up with for that, you'll be able to check that out as well.
- 1:01:27So that'll be in the show notes.
- 1:01:28Yeah.
- 1:01:28Great.
- 1:01:29Well, thanks a lot for having me.
- 1:01:30I really enjoyed the talk.
- 1:01:31Yeah.
- 1:01:32Thanks for coming back and helping us out with this Excel thing and getting more Jupyter and more pandas and more Python.
- 1:01:38Absolutely.
- 1:01:39Thank you.
- 1:01:39You bet.
- 1:01:40Bye.
- 1:01:40Bye.
- 1:01:41This has been another episode of Talk Python To Me.
- 1:01:44Our guest on this episode was Chris Moffitt, and it's been brought to you by Voyager, the video game, and Linode Cloud Hosting.
- 1:01:50Voyager is a game developed and published by Tolib Consulting.
- 1:01:54Travel the world in front of your computer and learn a whole lot.
- 1:01:58Visit talkpython.fm/Voyager or just search for Voyager on Steam.
- 1:02:03That's V-O-Y-A-G-E-R.
- 1:02:06Start your next Python project on Linode's state-of-the-art cloud service.
- 1:02:11Just visit talkpython.fm/Linode, L-I-N-O-D-E.
- 1:02:15You'll automatically get a $20 credit when you create a new account.
- 1:02:18Want to level up your Python?
- 1:02:20If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
- 1:02:25Or if you're looking for something more advanced, check out our new async course that digs into all the different types of async programming you can do in Python.
- 1:02:33And of course, if you're interested in more than one of these, be sure to check out our Everything Bundle.
- 1:02:38It's like a subscription that never expires.
- 1:02:40Be sure to subscribe to the show.
- 1:02:42Open your favorite podcatcher and search for Python.
- 1:02:44We should be right at the top.
- 1:02:46You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:02:55This is your host, Michael Kennedy.
- 1:02:57Thanks so much for listening.
- 1:02:58I really appreciate it.
- 1:02:59Now get out there and write some Python code.
- 1:03:01Thank you.
- 1:03:01Thank you.
- 1:03:02Thank you.
- 1:03:02Thank you.
- 1:03:02Thank you.
- 1:03:03Thank you.
- 1:03:03Thank you.
- 1:03:03Bye.
- 1:03:04Bye.
- 1:03:05Bye.
- 1:03:06Bye.
- 1:03:07Bye.
- 1:03:08Bye.
- 1:03:09Bye.
- 1:03:10Bye.
- 1:03:11Bye.
- 1:03:12Bye.
- 1:03:13Bye.
- 1:03:14Bye.
- 1:03:15Bye.
- 1:03:16Bye.
- 1:03:17Bye.
- 1:03:18you
- 1:03:19you
- 1:03:19Thank you.
- 1:03:21Thank you.