You could easily adjust this to a thousand or whatever number you want, and then it returns that data frame. I insert this function to create a hundred rows. And then from there I make sure to throw it into a data frame. In addition to that, I import that at the top level and at the D B T config context level so that D B T can recognize this as it's, um, performing. It created this respective table and it created a, a stored kind of standard procedure, or not standard procedure, but a stored procedure in order to make this come to life.Īnd so overall step by step is it creates, I create this helper function that generates fake data and this is where the determining the number of rows comes into play. It completed successfully created this fake data example. Go back here and then I'll show you the logs for what's going on over here. That's where I double checked the Snow Park libraries Anaconda canonical list, and it tells me exactly where it exists and that I can use it generates fake data. Step one, I'm importing the faker package and you're probably wondering how do I know that this is working with, uh, Snow Park in general? And that's, there's sometimes where I want to, you know, simulate unit testing in D B T or, um, play around with different scenarios or even instead of having, you know, different CSV seeds and hard coding that information, what if I wanna make that programmatic at the Python level and let Python do the heavy lifting for me to generate a hundred fake rows versus having to do that manually in Excel or CSV and then importing that directly here.Īnd so overall, I'm just gonna click this build button and I'll explain what's happening while this is running. The source code is pretty easy to understand as well.Īnd if you like what you see here, or on my Medium blog, and would like to see more of such helpful technical posts in the future, consider supporting me on Patreon and Github.Hey folks, this is Sun speaking here, and I'm gonna give a demo of creating fake data using D P T Python models.Īnd so let's figure out what problem this is solving for in the first place. So do head over to the package’s Github repo, take a look around, and take it for a spin. You can generate home phone and email, work phone and email, home address, work address, interests, profiles, credit cards, license plate numbers, and a lot more. You can generate any number of customers or friends (swing how ever you swing) very easily with a complete offline and online profile for each person. Nonetheless, this is definitely a very handy and fun package to have in your arsenal. But to generate one million customer records with first name, last name, email, phone, etc., it took almost 350 seconds on a 2019 16-inch base model MacBook Pro. It’s definitely easy to generate the data. See what I did there?Īctually, I’m not sure about the “quickly” part of my last sentence. I don’t know when you’d ever use, but you call Faker’s bs() any time you want. That’s supposed to be the company’s catch phrase.Īnd I kid you not, there’s a method called bs(). Providers of Horizontal value-added knowledge userĪs you can see from the output above, we provide some great horizontal value-added knowledge user. You can generate a whole company with for example: The company I just created! You can see now how easy it is to generate large amounts of fake customers, for testing of course. (faker.prefix_female(), faker.name_female(), faker.suffix_female(), faker.phone_number(), pany_email(), faker.address()) You can call me at %s, or email me at %s, or visit my home at %s" % Print("My name is %s %s %s, I'm a female. (faker.prefix_male(), faker.name_male(), faker.suffix_male(), faker.phone_number(), faker.ascii_company_email(), faker.address()) (faker.prefix_nonbinary(), faker.name_nonbinary(), faker.suffix_nonbinary(), faker.phone_number(), faker.ascii_free_email(), faker.address()) Print("My name is %s %s %s, I'm a gender neutral person. And the code I used to get this output is the following: from faker import Faker Looking at this, it’s amazing how realistic it looks. This is the output of a simple Python script that I wrote to generate fake customer data, or fake people. You can call me at 543.024.8936, or email me at or visit my home at 5144 Rubio Island You can call me at (276)611-1727, or email me at or visit my home at 7409 Peterson Locks Apt. You can call me at 001-09, or email me at or visit my home at 2703 Fitzpatrick Squares Suite 785 Linda Dunn III, I'm a gender neutral person. Faker = Faker(locale='en_US') Let’s look at what it can do firstīefore we dive into the code, let’s have a look at what it can do for us first.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |