Latest / CyberSecurity Summary / Practical Python Data Visualization: A Fast Track Approach To Learning Data Visualization With Python
Transcript
- 0:00Speaker 1: Welcome to the deep dive, where we take your chosen
- 0:02Speaker 1: sources and well distill them down to the essential insights. Right.
- 0:07Speaker 1: Think of us as your shirt cut to understanding what
- 0:09Speaker 1: really matters.
- 0:09Speaker 2: Yeah, cutting through the noise.
- 0:11Speaker 1: Today we're plunging into the world of Python data visualization,
- 0:15Speaker 1: guided by Ashwun Pajankar's book Practical Python Data Visualization, specifically for.
- 0:21Speaker 2: You, the learner, exactly, the learner, someone looking for that
- 0:24Speaker 2: efficient path to knowledge, those aha moments without getting you know,
- 0:28Speaker 2: bogged down. So our mission today is to explore pajon
- 0:32Speaker 2: Car's book, focusing on how it gets you from zero
- 0:35Speaker 2: to visualizing data effectively in Python. Okay, we'll be highlighting
- 0:40Speaker 2: the key concepts and practical steps from those initial chapters.
- 0:44Speaker 1: Okay, so where does pajon Car start. It's got to
- 0:46Speaker 1: be the foundation Python itself, right, yep? Chapter one. Now
- 0:49Speaker 1: Python's been around for a while, hasn't it. The book
- 0:52Speaker 1: mentions Guido van Rossum created it building on an older
- 0:55Speaker 1: language called ABC. That's right, first version way back in
- 0:58Speaker 1: ninety one. And it's interesting they even retired Python too
- 1:03Speaker 1: fairly recently. Shows it's still evolving.
- 1:05Speaker 2: Yeah, constantly. And what's fascinating about that evolution are the
- 1:09Speaker 2: Python Enhancement Proposals or PEPs PEPs okay. I think of
- 1:13Speaker 2: these as community driven proposals for how Python should grow
- 1:17Speaker 2: and improve. Pajankar highlights PK twenty The Zen of Python.
- 1:21Speaker 1: Ah, The Zen of Python. I love that. It's almost
- 1:24Speaker 1: like a philosophy for coders. It really is principles like
- 1:28Speaker 1: beautiful is better than ugly and readability counts. You might think, Okay,
- 1:32Speaker 1: how does that relate to making charts, But it really does,
- 1:35Speaker 1: doesn't it clear, Well written code just makes the whole
- 1:39Speaker 1: visualization process.
- 1:40Speaker 2: Smoother, absolutely easier to understand later easier to fix. These
- 1:44Speaker 2: principles are fundamental to why Python is so well user
- 1:48Speaker 2: friendly and why it's become such a go to language
- 1:51Speaker 2: across so many fields. The book touches on this diversity,
- 1:54Speaker 2: web development, gui's scientific, computing.
- 1:57Speaker 1: Even system administration.
- 1:58Speaker 2: Right includes a link to Python success stories, which really
- 2:02Speaker 2: illustrates just how widely it's used to solve real world problems.
- 2:06Speaker 1: So you could be visualizing I don't know, financial.
- 2:08Speaker 2: Trends or or mapping information spread It's incredibly versatile.
- 2:12Speaker 1: Now for actually getting Python onto your computer, the book
- 2:16Speaker 1: walks through installation for different systems. For Windows, it involves
- 2:21Speaker 1: downloading from python dot org. And this is important, making
- 2:24Speaker 1: sure you add Python to your path. Ah.
- 2:26Speaker 2: Yes, the path variable crucial.
- 2:28Speaker 1: It basically tells your computer where to find pythons so
- 2:31Speaker 1: you can run it from the command line. Then you
- 2:33Speaker 1: verify it with Python dash V and PIP three dash v.
- 2:36Speaker 1: That PIP three is your package installer, right, we'll need that.
- 2:39Speaker 2: Definitely for installing all the visualization libraries later. And for
- 2:43Speaker 2: Linux users like Ubuntu, Pujankar notes Python three and PIP
- 2:47Speaker 2: three are often already installed.
- 2:49Speaker 1: Convenient.
- 2:50Speaker 2: Yeah, just check with Python three dash V and PIP
- 2:52Speaker 2: three dash V. Knowing you have those tools ready is
- 2:56Speaker 2: step one.
- 2:56Speaker 1: Okay, tools ready. Then Pagencar introduces Python's different modes. There's
- 3:01Speaker 1: interactive mode.
- 3:02Speaker 2: Where you type code get instant results good for quick tests.
- 3:05Speaker 1: And script mode where you save your code and dot
- 3:08Speaker 1: wi files to run later more for actual programs exactly.
- 3:11Speaker 2: He also mentions IDL, which comes with Python.
- 3:14Speaker 1: Right, the Integrated Development and Learning Environment.
- 3:17Speaker 2: A simple editor to start writing and running. Python works
- 3:20Speaker 2: on Windows and Linux, and he shows.
- 3:21Speaker 1: That classic Hello World example. In both modes. It's a
- 3:26Speaker 1: small thing, but getting that first program to run always
- 3:29Speaker 1: feels good.
- 3:30Speaker 2: It does that solid Python foundation, then leads us straight
- 3:34Speaker 2: into chapter two and Jupiter Notebook.
- 3:36Speaker 1: Ah, Jupiter, okay, so way Jupiter. What's the advantage over
- 3:40Speaker 1: just the basic interactive mode.
- 3:42Speaker 2: Well, if you've ever been frustrated running code line by
- 3:44Speaker 2: line and you make a mistake and can't easily go back,
- 3:47Speaker 2: or you want to save your results with the code,
- 3:49Speaker 2: Jupiter is a game.
- 3:50Speaker 1: Changer, right. It fixes those issues.
- 3:53Speaker 2: The gen car describes it as a server program. You
- 3:55Speaker 2: run it and it lets you create these interactive notebooks
- 3:57Speaker 2: right in your web browser. Okay, in the browser interesting
- 4:00Speaker 2: hugely popular in research and data science because you can
- 4:04Speaker 2: mix your code the output, charts and tables, and even
- 4:09Speaker 2: text explanations all in one document.
- 4:11Speaker 1: So it's like a dynamic report where the analysis and
- 4:14Speaker 1: results live together.
- 4:15Speaker 2: Precisely. Setting it up is pretty straightforward. PIP three Install.
- 4:19Speaker 1: Jupiter using that PIT three again.
- 4:21Speaker 2: Yep. Then you launch it from your command line with
- 4:24Speaker 2: jupi notebook. It usually pops open in your browser at
- 4:26Speaker 2: localhost dot eight eight eight eight.
- 4:29Speaker 1: And there's sometimes a token.
- 4:30Speaker 2: Yeah, Pajuancar mentions the token it's just a security measure.
- 4:33Speaker 2: Make sure only you access your notebooks. Nothing to worry
- 4:36Speaker 2: about usually gotcha.
- 4:37Speaker 1: He gives a quick tour of the interface too.
- 4:39Speaker 2: He does the files tab for navigating, running tab to
- 4:42Speaker 2: see active notebooks, clusters for more advanced stuff.
- 4:46Speaker 1: But the core is creating a new Python three notebook.
- 4:49Speaker 2: Right and inside that you have these things.
- 4:51Speaker 1: Called cells cells. Yeah, I remember first using those. It
- 4:55Speaker 1: felt much more organized for trying.
- 4:57Speaker 2: Things out, definitely, And Pajankar points out the different types
- 5:00Speaker 2: code cells for your Python and markdown.
- 5:03Speaker 1: Cell arcdown for formatting text.
- 5:05Speaker 2: Exactly, for adding headings, notes, lists, making your notebook readable.
- 5:09Speaker 2: He shows a quick example, and these notebooks save as
- 5:12Speaker 2: ipomanbi files.
- 5:13Speaker 1: Dot ipmb okay keeps everything for.
- 5:16Speaker 2: A project together exactly, code, output, notes all in one place.
- 5:20Speaker 1: Okay, so we have Python setup, we have this interactive
- 5:23Speaker 1: Jupiter environment. Chapter three must be where the visualization starts, right.
- 5:27Speaker 2: It is first taste of visualization with a library called Leather.
- 5:30Speaker 1: Leather never heard of it.
- 5:32Speaker 2: Pajancar introduces it as a really user friendly way to
- 5:36Speaker 2: make basic charts quickly, simple syntax.
- 5:38Speaker 1: How do you get it?
- 5:39Speaker 2: You guessed it? PIP three install Leather huh? Okay, and
- 5:43Speaker 2: what's neat here is. Pajankar shows you can run operating
- 5:46Speaker 2: system commands directly from inside Jupiter using an exclamation mark
- 5:50Speaker 2: before the command. So you could do dot PIP three,
- 5:53Speaker 2: install leather, write in a cell or dull less to
- 5:56Speaker 2: list files. Pretty handy.
- 5:58Speaker 1: That is handy, let's jump around. He also mentions indentation right,
- 6:02Speaker 1: that's super important in Python, crucial.
- 6:04Speaker 2: He highlights it specifically. Unlike languages using curly braces, Python
- 6:08Speaker 2: uses white space indentation to structure cod blocks.
- 6:12Speaker 1: So it's not just for looks. It actually tells Python
- 6:14Speaker 1: how the code fits together exactly.
- 6:16Speaker 2: Get it wrong, you get errors.
- 6:18Speaker 1: Good warning. Okay. So plotting with letter how does that work?
- 6:21Speaker 2: The Junker demonstrates defining your data points and Leather is
- 6:25Speaker 2: quite flexible. Accepts data in a few formats like lists
- 6:28Speaker 2: of pairs.
- 6:28Speaker 1: Okay.
- 6:29Speaker 2: Then you create a chart object. Then you add things
- 6:32Speaker 2: to it like dots using chart dot ad dots makes sense. Finally,
- 6:37Speaker 2: to see it or save it, you use chart dot
- 6:38Speaker 2: to SVG. It outputs a scalable mector graphic file SVG.
- 6:43Speaker 1: Okay, so it's a pretty direct path. Uh, data chart
- 6:46Speaker 1: object ad elements output very direct.
- 6:48Speaker 2: He also shows tweaking the look, dot color size, and
- 6:52Speaker 2: plotting multiple sets of data on one chart.
- 6:55Speaker 1: Does leather handle colors automatically for multiple sets?
- 6:58Speaker 2: It does? Yeah, picks different default colors which helps distinguish them.
- 7:01Speaker 1: Nice. What else can leather do besides dots?
- 7:04Speaker 2: Pajunkar introduces lines with adline bar charts with AD bars
- 7:08Speaker 2: good for text categories, and column charts with AD columns.
- 7:11Speaker 1: So the basic chart types.
- 7:13Speaker 2: The fundamentals, Yeah, and shows simple ways to customize those two.
- 7:16Speaker 1: What about axes and scales as leather handled that it does?
- 7:19Speaker 2: He explains, it automatically figures out the right scale ordinal
- 7:22Speaker 2: for text, linear for numbers, temporal for dates, but you
- 7:26Speaker 2: can also manually set limits if you need more control,
- 7:28Speaker 2: say for the II axis range.
- 7:30Speaker 1: Okay, any other styling.
- 7:32Speaker 2: The chapter wraps up touching on styling options, setting specific
- 7:36Speaker 2: tick values on axes, changing the overall look with themes
- 7:39Speaker 2: via leather dot theme themes okay, and even a cool
- 7:43Speaker 2: example of making data point colors change based on their
- 7:46Speaker 2: position using a custom function, a little touch of dynamic viz.
- 7:50Speaker 1: Wow. Okay, So leather seems like a good starting point
- 7:53Speaker 1: for simple stuff.
- 7:54Speaker 2: That's the takeaway. Great entry point. But as Pajenkra points out,
- 7:57Speaker 2: for more complex, highly customized charts, you'll need the broader
- 8:01Speaker 2: scientific Python ecosystem.
- 8:03Speaker 1: Which brings us it chapter four the Powerhouse chapter exactly.
- 8:06Speaker 2: Chapter four introduces the SCIPI ecosystem. It's this collection of
- 8:11Speaker 2: libraries built for math, science, engineering, and Python.
- 8:14Speaker 1: Okay, so what's in this ecosystem.
- 8:15Speaker 2: Pajenkra lists the core players, Python itself obviously, numb PI
- 8:20Speaker 2: for numerical computing NUMBPI.
- 8:22Speaker 1: Heard a lot about that one.
- 8:23Speaker 2: The SIPE library itself, which has tons of mathematical routines,
- 8:26Speaker 2: and matt plotlib for more advanced plotting matte plotlib.
- 8:30Speaker 1: Okay, so that's the step up from Letter definitely.
- 8:33Speaker 2: He also mentions other key libraries pandas for data analysis.
- 8:37Speaker 1: Like working with tables, ah Pantas.
- 8:39Speaker 2: SIMPI for symbolic math, psychic image for image processing, psyche
- 8:43Speaker 2: learn for machine learning. It's a whole toolkit.
- 8:45Speaker 1: Wow. Quite the ecosystem, and.
- 8:46Speaker 2: He reminds us Jupiter notebook is often the interactive environment
- 8:50Speaker 2: where you use all these together.
- 8:51Speaker 1: Makes sense, So the chapter dies into numb PI.
- 8:54Speaker 2: It focuses on numb PI and its core data structure.
- 8:57Speaker 2: The underay n dimensional array deray.
- 9:00Speaker 1: What is that exactly?
- 9:01Speaker 2: Pajunker explains, it's like a super efficient container for numerical data. Importantly,
- 9:06Speaker 2: all items in an under ray have the same data.
- 9:09Speaker 1: Type, ah, same type. Why is that important?
- 9:12Speaker 2: Speed? Yeah, That uniformity makes calculations incredibly fast compared to
- 9:16Speaker 2: standard Python lists.
- 9:18Speaker 1: Got it? How do you make one?
- 9:19Speaker 2: He shows creating them from Python lists using np dot array.
- 9:23Speaker 2: You can also specify the data type using d.
- 9:25Speaker 1: Type okay, and accessing.
- 9:27Speaker 2: Elements standard indexing using square brackets, both positive indices starting
- 9:32Speaker 2: from zero and negative indices counting from the end, like.
- 9:35Speaker 1: Myra's eer for the first, myra one for the last.
- 9:38Speaker 2: Exactly, and he points out, try to access something that
- 9:41Speaker 2: isn't there, you get an index error.
- 9:43Speaker 1: Good to know. What about more dimensions like tables?
- 9:47Speaker 2: Yet he moves on to two d arrays like matrices
- 9:50Speaker 2: or tables, and even three d arrays. Shows how indexing
- 9:52Speaker 2: works there too, to get specific elements or entire rows or.
- 9:55Speaker 1: Columns, slicing and dicing the data.
- 9:57Speaker 2: Pretty much. That ability to sele elect and manipulate parts
- 10:01Speaker 2: of your data easily is a key numb Pie strength.
- 10:04Speaker 1: What else about injuries properties.
- 10:06Speaker 2: Briefly runs through useful properties indem for number of dimensions,
- 10:10Speaker 2: shape for the size of each.
- 10:11Speaker 1: Dimension like rows and columns in two D, right.
- 10:14Speaker 2: D type for the data type again, size for total elements,
- 10:16Speaker 2: invites for memory usage, and t for the.
- 10:18Speaker 1: Transpos transpose flips, rose and columns.
- 10:21Speaker 2: Yep, just useful ways to understand the structure of your array.
- 10:24Speaker 1: Anything else in the numpie chapter.
- 10:26Speaker 2: It finishes by listing some handy built in NUMPI constants
- 10:30Speaker 2: np dot an f or infinity, np dot n n
- 10:33Speaker 2: n for not a number.
- 10:34Speaker 1: You see nana lot in real data.
- 10:36Speaker 2: Very common and mathematical constants like np dot t i
- 10:39Speaker 2: and npe useful for calculation.
- 10:41Speaker 1: Okay, so chapter four gives us numb Pi for handling
- 10:44Speaker 1: the numbers efficiently. Chapter five must be putting it together
- 10:47Speaker 1: with mattplotlib for visualization.
- 10:49Speaker 2: You got it. Chapter five data visualization with numb Pi
- 10:52Speaker 2: and matt Plotlib.
- 10:54Speaker 1: Finally, Matt plotlip.
- 10:55Speaker 2: Pajanker introduces it as a fundamental plotting library in the
- 10:59Speaker 2: siepi world. Actually inspired by Matt Labs plotting.
- 11:02Speaker 1: Ah.
- 11:03Speaker 2: Okay, installation kit three, install matt plotlib standard stuff and
- 11:08Speaker 2: using it in code typically import mattplotlib dot pieplot as PLTKA.
- 11:12Speaker 2: Giving it that short name PLT is convention. And if
- 11:15Speaker 2: you're in Jupiter, that magic command percent matt plotlib inline
- 11:20Speaker 2: is key.
- 11:20Speaker 1: What that again tells.
- 11:21Speaker 2: Jupiter to display your plots right there in the notebook
- 11:24Speaker 2: output below the code cell very convenient.
- 11:26Speaker 1: Right and import numpi two.
- 11:28Speaker 2: Oh yeah important NumPy as np. Mattplotlib works hand in
- 11:31Speaker 2: glove with numpi erase.
- 11:33Speaker 1: Okay, Import's done. How do we create data to plot?
- 11:36Speaker 1: He mentioned numpike creation routines.
- 11:37Speaker 2: He did first up is np dot arrange creates evenly
- 11:41Speaker 2: spaced numbers and arrange like.
- 11:42Speaker 1: Zero, one, two three or zero point five to one
- 11:45Speaker 1: point zero exactly.
- 11:46Speaker 2: You have to give it the stop value, but start
- 11:48Speaker 2: and step size are optional. He shows examples, including making
- 11:51Speaker 2: x values for a simple y x plot.
- 11:54Speaker 1: Okay, arrange what else np.
- 11:56Speaker 2: Dot limb space similar, but instead of step size you
- 11:58Speaker 2: give it start, stop and how many points you want
- 12:00Speaker 2: in between evenly spaced ah.
- 12:03Speaker 1: Useful if you need exactly, say, one hundred points across
- 12:06Speaker 1: a range precisely.
- 12:07Speaker 2: Pudge on car shows an example, and how to turn
- 12:09Speaker 2: off plot axes with plt dot axsis just to see
- 12:12Speaker 2: the generated.
- 12:13Speaker 1: Points interesting any others.
- 12:15Speaker 2: Briefly mentions np dot log space and np dot gm
- 12:18Speaker 2: space for logarithmically or geometrically spaced values. Useful for certain
- 12:22Speaker 2: plots like log scales, shows their output visually.
- 12:25Speaker 1: Good to know they exist. So we have data, How
- 12:28Speaker 1: do we plot it?
- 12:29Speaker 2: The core function is PLT dot plot. He shows using
- 12:32Speaker 2: it with both Python lists and numbpi arrays to create
- 12:35Speaker 2: single line plots. Demonstrates a simple curve while by two.
- 12:39Speaker 1: Okay, PLT dot plot. How about multiple lines on one chart?
- 12:42Speaker 2: Two ways either call plt dot plot multiple times for
- 12:45Speaker 2: each line, or you can sometimes provide multiple y value
- 12:47Speaker 2: rays to a single PLT dot plot. Mattplot lib handles
- 12:50Speaker 2: the different colors automatically.
- 12:52Speaker 1: Nice, But plots need labels and stuff right absolutely.
- 12:55Speaker 2: Pa gen car covers the essentials adding a grid PLT
- 12:58Speaker 2: dot grid true. Saving the plot PLT dot save fig,
- 13:02Speaker 2: myplot dot png.
- 13:03Speaker 1: Save fig important. What about axis limits.
- 13:05Speaker 2: PLT dot axis for setting all limits at once, or
- 13:08Speaker 2: p l t dot XLM and p lt dot XLM
- 13:10Speaker 2: for individual control over the x and y ranges. Good
- 13:14Speaker 2: titles and axis labels PLT dot title p l T
- 13:16Speaker 2: dot rabel and p l T dot label really crucial
- 13:20Speaker 2: for making plots understandable.
- 13:21Speaker 1: Definitely need those. What about legends If you have multiple lines.
- 13:25Speaker 2: Use the label argument inside p l T dot plot
- 13:28Speaker 2: for each line like p l T dot plot x
- 13:30Speaker 2: y one label data set one, then call PLT dot
- 13:33Speaker 2: legend to display it, and.
- 13:34Speaker 1: You can control where the legend appears.
- 13:36Speaker 2: Using the lock argument in PLT dot legend like upper
- 13:39Speaker 2: left or best to let matplot lib decide.
- 13:41Speaker 1: Okay, making it informative, Now making it look good.
- 13:44Speaker 2: Colors lines big part of chapter five. He details changing
- 13:47Speaker 2: colors with short codes like R for red, G, green,
- 13:50Speaker 2: b blue, simple codes, changing line styles solid, dah, dash, dash, dash,
- 13:54Speaker 2: dot is, adding markers to data points, et cetera. Lots
- 13:57Speaker 2: of options. You can combine these format strings like row
- 14:00Speaker 2: for red, circle markers dash line.
- 14:03Speaker 1: Combines color marker and lin style.
- 14:05Speaker 2: Hmm efficient Yeah. And then he shows more detailed control
- 14:09Speaker 2: using keyword arguments in PLT dot plot like what things
- 14:13Speaker 2: like colored red line style dashed line with two marcro
- 14:18Speaker 2: markerface color blue marker size ten, much finer control.
- 14:22Speaker 1: Wow, lots of options there. Anything else on customization.
- 14:26Speaker 2: Finishes with customizing the tick marks the actual number shown
- 14:29Speaker 2: on the axes. Using PLT dot x sticks and PLT
- 14:32Speaker 2: dot tics, you can set the positions and even the
- 14:34Speaker 2: labels for the ticks.
- 14:35Speaker 1: So really fine grain control over how the axes look exactly.
- 14:38Speaker 2: Matt plotlib gives you that power building on NUMPI data.
- 14:41Speaker 1: So looking back at these initial chapters of practical Python
- 14:44Speaker 1: data visualization, we've covered quite a bit of ground.
- 14:47Speaker 2: We really have, from just getting Python running, setting up
- 14:50Speaker 2: that interactive Jupiter environment, yeah, to a first taste of
- 14:54Speaker 2: plotting with leather, and then diving into the core tools
- 14:57Speaker 2: numbpi for the numbers and matt plotlib for them the pictures.
- 15:00Speaker 1: Absolutely, and it's quite striking how even these early chapters
- 15:04Speaker 1: give you a solid toolkit. You're not just looking at data,
- 15:07Speaker 1: you're equipped to actually bring into life visually.
- 15:10Speaker 2: Going from raw numbers to creating and customizing fundamental charts.
- 15:15Speaker 2: It's a powerful first step.
- 15:17Speaker 1: It really makes you think, doesn't it. How could this ability,
- 15:20Speaker 1: even with these basic forms of visualization, change how you
- 15:24Speaker 1: understand or communicate information in your own field?
- 15:28Speaker 2: Yeah? Consider the data you see regularly, could using PLT
- 15:32Speaker 2: dot plot or even simple leather charts reveal patterns or
- 15:35Speaker 2: insights you just haven't noticed before. Turning numbers into stories.
- 15:39Speaker 1: Definitely food for thought, and as pajunker shows, there are
- 15:42Speaker 1: pathways for going Deever, those PEP docs, the full map
- 15:45Speaker 1: plot lib documentation.
- 15:46Speaker 2: You mentioned, there's a whole universe of more advanced techniques,
- 15:49Speaker 2: different libraries, specialized charts out there.
- 15:52Speaker 1: Perhaps in future deep dives we could explore some of
- 15:54Speaker 1: those more advanced tools or look at specific real world applications.
- 15:58Speaker 2: That'll be interesting. The possibility to these with Python visualization
- 16:01Speaker 2: are well pretty exciting.