课程: Advanced Python: Working With Data
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Data transformation
- [Instructor] Data doesn't always come in the form that you would like it to. So you might find yourself in a situation where you need to transform the data from one format into another. Python provides a function that can help with this. It's called the map function. The map function creates an iterator that takes one or more sequences of values and produces a new sequence by applying a given function to each value in the original sequences. So let's try a couple of simple examples and I'm going to open up my transform.py file. All right, so let's imagine that I've got a couple of sample data sets here, right. So down here, if I scroll down I've got a couple of sequences, right. This one here is numbers, actually. Well, they're both numbers, okay. And so let's imagine that I wanted to convert each of the numbers in this nums sequence to the square of the original number that's in the list. All right. So I can easily…