课程: Hands-On Advanced Python: Data Engineering Basics

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Random operations on sequences

Random operations on sequences

- [Instructor] In a previous video, we saw how to use the random module to generate random numbers in a variety of ways. In this example, we're going to take a look at some of the functions in the random module that are specifically intended to be used with sequences of values. So let's open up our random operations, and give ourselves a little room to work here. So I have some initial code that selects the first 30 days from the weather dataset after it is loaded and parsed by the JSON module. So first, let's see how the shuffle function works. This function is used to shuffle a set of data in place, sort of like how you would shuffle a deck of playing cards. So let's write some code that prints out the first three days of the data, and I'll use the pre-print module for this, and I'll print out the month_data, and we'll choose the first three days, and then we'll print out some dividing line, right? And then we'll call…

内容