Python 3 Mimesis Library Script to Generate Random API User Dataframe From Schema Using Pandas
Jun 3, 2025
Get the full source code of application here:
https://codingshiksha.com/python/python-3-mimesis-library-script-to-generate-random-api-user-dataframe-from-schema-using-pandas/
Show More Show Less View Video Transcript
0:00
uh hello guys welcome to this video so
0:02
in this video I will show you yet
0:03
another Python open-source package for
0:06
generating random set of tabular user
0:08
data for API testing or any sort of
0:11
testing so this is actually a Python
0:14
script that I developed it uses also
0:16
pandas library as well and here uh if I
0:20
execute this first of all you do need to
0:24
import the necessary packages here so
0:26
one such pack package is using is
0:29
mimicis which is a popular package
0:33
for generating random set of data so the
0:36
command is simple you simply install
0:38
this pip install mimmesis this is
0:41
actually the package name
0:43
here so after you import this now we can
0:46
set uh run this python script here as
0:49
soon as you can see the data has been
0:51
generated and saved in a CSV file
0:56
and you can see it contains two columns
0:59
here you can have as much column names
1:01
as you want we have the two string
1:03
columns name and country so every time
1:06
you generate this these names these
1:09
countries will be
1:12
uh random here you can see again the
1:14
data has been generated and it's
1:18
random so now let me show you how to get
1:21
started the full source code is given in
1:23
the description of this video so first
1:25
of all you import the package from
1:29
mimises we need to import the necessary
1:32
packages which is person address and
1:36
date
1:37
time and then from mimises
1:42
enums we need to import also the
1:47
gender so you can basically it has a
1:49
predefined set of random data types that
1:54
you can import and also we also need to
1:57
import the pandas libraries for
1:59
exporting this data to CSV and now we
2:03
initialize the actual person so here we
2:06
will
2:07
provide what sort of person you want so
2:10
I will be wanting it in English language
2:13
and then the second data type will be an
2:16
address
2:17
so it will also be in English language
2:20
so then we initialize the data frame so
2:23
this will be of type data time so we
2:26
initialize all the providers here and
2:28
then we set the today's date by date dot
2:32
today and then we simply run a simple
2:35
for
2:37
loop and we run it for 100 times to
2:40
generate 100 set of unique users so here
2:44
we'll be appending this data here
2:48
data.append so here we'll be containing
2:50
these two columns the name of the person
2:53
of so person dot full name it contains
2:57
this function which
2:59
generates so here you can even set the
3:02
gender as well what sort of gender name
3:05
you want so I will set it to female and
3:08
then for the country you can actually
3:12
say address dot country so it has a
3:15
predefined methods guys you can see for
3:17
generating random data you can check out
3:19
their documentation after that now you
3:22
can export all this data data frames
3:25
here so we simply using pandas library
3:29
so we can use the data frame and pass
3:32
the data and export this data
3:35
to CSV so it also has methods for
3:39
exporting it to Excel as
3:41
well so here you can set the file name
3:44
so data dot CSV and
3:50
index so here you can see data
4:04
generated sorry it
4:06
is enums
4:09
is sus
4:12
singular data is not defined did you
4:15
mean
4:17
date line number
4:25
50 uh let me see what is okay we haven't
4:30
defined the data so just define a
4:32
variable for data this will be an empty
4:34
array just define
4:38
this you'll see data generated and uh it
4:41
has created this data dot CSV file so
4:44
it's a very useful package inside Python
4:47
for generating random data and uh if you
4:50
just search it on this website you will
4:53
find out this package mimis it's a very
4:56
popular package fake data generator for
4:58
applications so you can provide schema
5:02
here as well you can check out their
5:04
documentation it's a very good module
5:06
for uh fake data generator and also
5:09
check out my website
5:11
freemediatoolshu.com
5:13
uh which contains uh thousands of tools
#Programming
#Scripting Languages
