{"id":46717,"date":"2022-08-19T00:00:00","date_gmt":"2022-08-19T07:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/"},"modified":"2025-11-13T12:56:09","modified_gmt":"2025-11-13T20:56:09","slug":"exploring-consumer-purchases-patterns-using-griddb-and-python","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/","title":{"rendered":"Exploring Consumer Purchases Patterns using GridDB and Python"},"content":{"rendered":"<p>Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer follows his or her own set of buying patterns. By recognizing, analyzing, and measuring buying patterns, businesses can gain a better understanding of their target audience and potentially expand their reach.<\/p>\n<p>The repo for this blog can be found here: https:\/\/github.com\/griddbnet\/Blogs\/tree\/exploring_consumer_purchases<\/p>\n<p>The objective of this blog is to analyze the buying behavior of Google Merchandise Store customers using the power of GridDB. The results of the analysis might lead to more actionable operational changes and better use of marketing budgets for those companies who choose to use data analysis on top of Google analytics data.<\/p>\n<p><a href=\"https:\/\/github.com\/griddbnet\/Blogs\/blob\/exploring_consumer_purchases\/Exploring%20Consumer%20Purchases%20Patterns%20using%20GridDB%20and%20Python\/Exploring%20Consumer%20Purchases%20Patterns%20using%20GridDB%20and%20Python.ipynb\"> Full Jupyter File found here <\/a><\/p>\n<p>The outline of the tutorial is as follows:<\/p>\n<ol>\n<li>Dataset overview<\/li>\n<li>Importing required libraries<\/li>\n<li>Loading the dataset<\/li>\n<li>Data Cleaning and Preprocessing<\/li>\n<li>Analysing with data visualization<\/li>\n<li>Conclusion<\/li>\n<\/ol>\n<h2>Prerequisites and Environment setup<\/h2>\n<p>This tutorial is carried out in Anaconda Navigator (Python version \u2013 3.8.3) on Windows Operating System. The following packages need to be installed before you continue with the tutorial \u2013<\/p>\n<ol>\n<li>\n<p>Pandas<\/p>\n<\/li>\n<li>\n<p>NumPy<\/p>\n<\/li>\n<li>\n<p>plotly<\/p>\n<\/li>\n<li>\n<p>Matplotlib<\/p>\n<\/li>\n<li>\n<p>Seaborn<\/p>\n<\/li>\n<li>\n<p>griddb_python<\/p>\n<\/li>\n<li>\n<p>scipy<\/p>\n<\/li>\n<li>\n<p>json<\/p>\n<\/li>\n<li>\n<p>squarify<\/p>\n<\/li>\n<li>\n<p>random<\/p>\n<\/li>\n<\/ol>\n<p>You can install these packages in Conda\u2019s virtual environment using <code>conda install package-name<\/code>. In case you are using Python directly via terminal\/command prompt, <code>pip install package-name<\/code> will do the work.<\/p>\n<h2>GridDB installation<\/h2>\n<p>While loading the dataset, this tutorial will cover two methods \u2013 Using GridDB as well as Using Pandas. To access GridDB using Python, the following packages also need to be installed beforehand:<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/griddb\/c_client\">GridDB C-client<\/a><\/li>\n<li>SWIG (Simplified Wrapper and Interface Generator)<\/li>\n<li><a href=\"https:\/\/github.com\/griddb\/python_client\">GridDB Python Client<\/a><\/li>\n<\/ol>\n<h2>1&#46; Dataset Overview<\/h2>\n<p>The dataset contains information about visits to GStore (Google swag online store), each row is a unique visit and each user has a unique &#8216;fullVisitorId&#8217;.<\/p>\n<p>1) <code>fullVisitorId<\/code>&#8211; A unique identifier for each user of the Google Merchandise Store.<\/p>\n<p>2) <code>channelGrouping<\/code> &#8211; The channel via which the user came to the Store.<\/p>\n<p>3) <code>date<\/code> &#8211; The date on which the user visited the Store.<\/p>\n<p>4) <code>device<\/code> &#8211; The specifications for the device used to access the Store.<\/p>\n<p>5) <code>geoNetwork<\/code> &#8211; This section contains information about the geography of the user.<\/p>\n<p>6) <code>socialEngagementType<\/code> &#8211; Engagement type, either &#8220;Socially Engaged&#8221; or &#8220;Not Socially Engaged&#8221;.<\/p>\n<p>7) <code>totals<\/code> &#8211; This section contains aggregate values across the session.<\/p>\n<p>8) <code>trafficSource<\/code> &#8211; This section contains information about the Traffic Source from which the session originated.<\/p>\n<p>9) <code>visitId<\/code> &#8211; An identifier for this session. This is part of the value usually stored as the _utmb cookie. This is only unique to the user. For a completely unique ID, you should use a combination of fullVisitorId and visitId.<\/p>\n<p>10) <code>visitNumber<\/code> &#8211; The session number for this user. If this is the first session, then this is set to 1.<\/p>\n<p>11) <code>visitStartTime<\/code> &#8211; The timestamp (expressed as POSIX time).<\/p>\n<p>12) <code>hits<\/code> &#8211; This row and nested fields are populated for any and all types of hits. Provides a record of all page visits.<\/p>\n<p>13) <code>customDimensions<\/code> &#8211; This section contains any user-level or session-level custom dimensions that are set for a session. This is a repeated field and has an entry for each dimension that is set.<\/p>\n<p>14) <code>totals<\/code> &#8211; This set of columns mostly includes high-level aggregate data.<\/p>\n<p>https:\/\/www.kaggle.com\/competitions\/ga-customer-revenue-prediction\/data?select=train.csv<\/p>\n<h2>2&#46; Importing Required Libraries<\/h2>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">import griddb_python as griddb\n\nimport gc\nimport numpy as np\nimport pandas as pd\nfrom pandas.io.json import json_normalize\nfrom scipy.stats import norm\nimport json\nimport datetime\nimport random\n\nimport squarify\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom plotly.offline import init_notebook_mode, iplot\nimport plotly.graph_objs as go\nfrom plotly import tools\n\nimport warnings\nwarnings.filterwarnings('ignore')\n%matplotlib inline<\/code><\/pre>\n<\/div>\n<h2>3&#46; Loading the Dataset<\/h2>\n<p>Let\u2019s proceed and load the dataset into our notebook.<\/p>\n<h3>3&#46;a Using GridDB<\/h3>\n<p>Toshiba GridDB\u2122 is a highly scalable NoSQL database best suited for IoT and Big Data. The foundation of GridDB\u2019s principles is based upon offering a versatile data store that is optimized for IoT, provides high scalability, tuned for high performance, and ensures high reliability.<\/p>\n<p>To store large amounts of data, a CSV file can be cumbersome. GridDB serves as a perfect alternative as it in open-source and a highly scalable database. GridDB is a scalable, in-memory, No SQL database which makes it easier for you to store large amounts of data. If you are new to GridDB, a tutorial on <a href=\"https:\/\/griddb.net\/en\/blog\/using-pandas-dataframes-with-griddb\/\">reading and writing to GridDB<\/a> can be useful.<\/p>\n<p>Assuming that you have already set up your database, we will now write the SQL query in python to load our dataset.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">factory = griddb.StoreFactory.get_instance()\n\nInitialize the GridDB container (enter your database credentials)\ntry:\n    gridstore = factory.get_store(host=host_name, port=your_port, \n            cluster_name=cluster_name, username=admin, \n            password=admin)\n\n    info = griddb.ContainerInfo(\"customer_data\",\n                    [[\"channelGrouping\", griddb.Type.STRING],[\"geoNetwork\", griddb.Type.STRING],[\"device\", griddb.Type.STRING],\n                     [\"date\", griddb.Type.TIMESTAMP],[\"sessionId\", griddb.Type.STRING],[\"socialEngagementType\", griddb.Type.STRING],\n                     [\"totals\", griddb.Type.STRING],[\"trafficSource\", griddb.Type.STRING],[\"visitStartTime\", griddb.Type.TIMESTAMP],\n                     [\"fullVisitorId\", griddb.Type.INTEGER],[\"visitNumber\", griddb.Type.INTEGER],[\"visitId\", griddb.Type.INTEGER],\n                    griddb.ContainerType.COLLECTION, True)\n    cont = gridstore.put_container(info) \n    data = pd.read_csv(\"False.csv\")\n    #Add data\n    for i in range(len(data)):\n        ret = cont.put(data.iloc[i, :])\n        print(\"Data added successfully\")<\/code><\/pre>\n<\/div>\n<pre><code>Data added successfully\n<\/code><\/pre>\n<p>The read_sql_query function offered by the pandas library converts the data fetched into a panda data frame to make it easy for the user to work.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">sql_statement = ('SELECT * FROM customer_data.csv')\ndf = pd.read_sql_query(sql_statement, cont)<\/code><\/pre>\n<\/div>\n<p>Note that the <code>cont<\/code> variable has the container information where our data is stored. Replace the <code>credit_card_dataset<\/code> with the name of your container. More info can be found in this tutorial <a href=\"https:\/\/griddb.net\/en\/blog\/using-pandas-dataframes-with-griddb\/\">reading and writing to GridDB<\/a>.<\/p>\n<p>When it comes to IoT and Big Data use cases, GridDB clearly stands out among other databases in the Relational and NoSQL space. Overall, GridDB offers multiple reliability features for mission-critical applications that require high availability and data retention.<\/p>\n<h3>3&#46;b Using pandas read_csv<\/h3>\n<p>We can also use Pandas&#8217; <code>read_csv<\/code> function to load our data. Both of the above methods will lead to the same output as the data is loaded in the form of a pandas dataframe using either of the methods.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">df = pd.read_csv(\"customer_data.csv\")<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">df.head()<\/code><\/pre>\n<\/div>\n<div style=\"overflow: auto;\">\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }<\/p>\n<p>    .dataframe tbody tr th {\n        vertical-align: top;\n    }<\/p>\n<p>    .dataframe thead th {\n        text-align: right;\n    }\n  <\/style>\n<table border=\"1\" class=\"dataframe\" style=\"white-space: nowrap;\">\n<thead>\n<tr style=\"text-align: right;\">\n<th>\n        <\/th>\n<th>\n          channelGrouping\n        <\/th>\n<th>\n          date\n        <\/th>\n<th>\n          device\n        <\/th>\n<th>\n          fullVisitorId\n        <\/th>\n<th>\n          geoNetwork\n        <\/th>\n<th>\n          sessionId\n        <\/th>\n<th>\n          socialEngagementType\n        <\/th>\n<th>\n          totals\n        <\/th>\n<th>\n          trafficSource\n        <\/th>\n<th>\n          visitId\n        <\/th>\n<th>\n          visitNumber\n        <\/th>\n<th>\n          visitStartTime\n        <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>\n          0\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          {&#8220;browser&#8221;: &#8220;Chrome&#8221;, &#8220;browserVersion&#8221;: &#8220;not a&#8230;\n        <\/td>\n<td>\n          1131660440785968503\n        <\/td>\n<td>\n          {&#8220;continent&#8221;: &#8220;Asia&#8221;, &#8220;subContinent&#8221;: &#8220;Western&#8230;\n        <\/td>\n<td>\n          1131660440785968503_1472830385\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          {&#8220;visits&#8221;: &#8220;1&#8221;, &#8220;hits&#8221;: &#8220;1&#8221;, &#8220;pageviews&#8221;: &#8220;1&#8221;,&#8230;\n        <\/td>\n<td>\n          {&#8220;campaign&#8221;: &#8220;(not set)&#8221;, &#8220;source&#8221;: &#8220;google&#8221;, &#8230;\n        <\/td>\n<td>\n          1472830385\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472830385\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          1\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          {&#8220;browser&#8221;: &#8220;Firefox&#8221;, &#8220;browserVersion&#8221;: &#8220;not &#8230;\n        <\/td>\n<td>\n          377306020877927890\n        <\/td>\n<td>\n          {&#8220;continent&#8221;: &#8220;Oceania&#8221;, &#8220;subContinent&#8221;: &#8220;Aust&#8230;\n        <\/td>\n<td>\n          377306020877927890_1472880147\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          {&#8220;visits&#8221;: &#8220;1&#8221;, &#8220;hits&#8221;: &#8220;1&#8221;, &#8220;pageviews&#8221;: &#8220;1&#8221;,&#8230;\n        <\/td>\n<td>\n          {&#8220;campaign&#8221;: &#8220;(not set)&#8221;, &#8220;source&#8221;: &#8220;google&#8221;, &#8230;\n        <\/td>\n<td>\n          1472880147\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472880147\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          2\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          {&#8220;browser&#8221;: &#8220;Chrome&#8221;, &#8220;browserVersion&#8221;: &#8220;not a&#8230;\n        <\/td>\n<td>\n          3895546263509774583\n        <\/td>\n<td>\n          {&#8220;continent&#8221;: &#8220;Europe&#8221;, &#8220;subContinent&#8221;: &#8220;South&#8230;\n        <\/td>\n<td>\n          3895546263509774583_1472865386\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          {&#8220;visits&#8221;: &#8220;1&#8221;, &#8220;hits&#8221;: &#8220;1&#8221;, &#8220;pageviews&#8221;: &#8220;1&#8221;,&#8230;\n        <\/td>\n<td>\n          {&#8220;campaign&#8221;: &#8220;(not set)&#8221;, &#8220;source&#8221;: &#8220;google&#8221;, &#8230;\n        <\/td>\n<td>\n          1472865386\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472865386\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          3\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          {&#8220;browser&#8221;: &#8220;UC Browser&#8221;, &#8220;browserVersion&#8221;: &#8220;n&#8230;\n        <\/td>\n<td>\n          4763447161404445595\n        <\/td>\n<td>\n          {&#8220;continent&#8221;: &#8220;Asia&#8221;, &#8220;subContinent&#8221;: &#8220;Southea&#8230;\n        <\/td>\n<td>\n          4763447161404445595_1472881213\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          {&#8220;visits&#8221;: &#8220;1&#8221;, &#8220;hits&#8221;: &#8220;1&#8221;, &#8220;pageviews&#8221;: &#8220;1&#8221;,&#8230;\n        <\/td>\n<td>\n          {&#8220;campaign&#8221;: &#8220;(not set)&#8221;, &#8220;source&#8221;: &#8220;google&#8221;, &#8230;\n        <\/td>\n<td>\n          1472881213\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472881213\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          4\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          {&#8220;browser&#8221;: &#8220;Chrome&#8221;, &#8220;browserVersion&#8221;: &#8220;not a&#8230;\n        <\/td>\n<td>\n          27294437909732085\n        <\/td>\n<td>\n          {&#8220;continent&#8221;: &#8220;Europe&#8221;, &#8220;subContinent&#8221;: &#8220;North&#8230;\n        <\/td>\n<td>\n          27294437909732085_1472822600\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          {&#8220;visits&#8221;: &#8220;1&#8221;, &#8220;hits&#8221;: &#8220;1&#8221;, &#8220;pageviews&#8221;: &#8220;1&#8221;,&#8230;\n        <\/td>\n<td>\n          {&#8220;campaign&#8221;: &#8220;(not set)&#8221;, &#8220;source&#8221;: &#8220;google&#8221;, &#8230;\n        <\/td>\n<td>\n          1472822600\n        <\/td>\n<td>\n          2\n        <\/td>\n<td>\n          1472822600\n        <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>4&#46; Data Cleaning and Preprocessing<\/h2>\n<p>There are 12 original columns, but four of them have a json object that can be converted:<\/p>\n<p>device: 16 new columns, geoNetwork: 11 new columns, totals: 6 new columns, trafficSource: 14 new columns<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">def load_df(nrows=None):\n    \n    Columns = ['device', 'geoNetwork', 'totals', 'trafficSource']\n    df = pd.read_csv('customer_data.csv',\n                     converters={column: json.loads for column in Columns}, \n                     dtype={'fullVisitorId': 'str'}, nrows=nrows)\n    \n    for column in Columns:\n        column_as_df = json_normalize(df[column])\n        column_as_df.columns = [f\"{column}_{subcolumn}\" for subcolumn in column_as_df.columns]\n        df = df.drop(column, axis=1).merge(column_as_df, right_index=True, left_index=True)\n    return df<\/code><\/pre>\n<\/div>\n<p>Combining the two datasets into one and adding the columns text and title into one column.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">df = load_df()\ndf.head()<\/code><\/pre>\n<\/div>\n<div style=\"overflow: auto;\">\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }<\/p>\n<p>    .dataframe tbody tr th {\n        vertical-align: top;\n    }<\/p>\n<p>    .dataframe thead th {\n        text-align: right;\n    }\n  <\/style>\n<table border=\"1\" class=\"dataframe\" style=\"white-space: nowrap;\">\n<thead>\n<tr style=\"text-align: right;\">\n<th>\n        <\/th>\n<th>\n          channelGrouping\n        <\/th>\n<th>\n          date\n        <\/th>\n<th>\n          fullVisitorId\n        <\/th>\n<th>\n          sessionId\n        <\/th>\n<th>\n          socialEngagementType\n        <\/th>\n<th>\n          visitId\n        <\/th>\n<th>\n          visitNumber\n        <\/th>\n<th>\n          visitStartTime\n        <\/th>\n<th>\n          device_browser\n        <\/th>\n<th>\n          device_browserVersion\n        <\/th>\n<th>\n          &#8230;\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.criteriaParameters\n        <\/th>\n<th>\n          trafficSource_isTrueDirect\n        <\/th>\n<th>\n          trafficSource_referralPath\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.page\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.slot\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.gclId\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.adNetworkType\n        <\/th>\n<th>\n          trafficSource_adwordsClickInfo.isVideoAd\n        <\/th>\n<th>\n          trafficSource_adContent\n        <\/th>\n<th>\n          trafficSource_campaignCode\n        <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>\n          0\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          1131660440785968503\n        <\/td>\n<td>\n          1131660440785968503_1472830385\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          1472830385\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472830385\n        <\/td>\n<td>\n          Chrome\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          &#8230;\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          1\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          377306020877927890\n        <\/td>\n<td>\n          377306020877927890_1472880147\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          1472880147\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472880147\n        <\/td>\n<td>\n          Firefox\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          &#8230;\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          2\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          3895546263509774583\n        <\/td>\n<td>\n          3895546263509774583_1472865386\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          1472865386\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472865386\n        <\/td>\n<td>\n          Chrome\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          &#8230;\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          3\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          4763447161404445595\n        <\/td>\n<td>\n          4763447161404445595_1472881213\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          1472881213\n        <\/td>\n<td>\n          1\n        <\/td>\n<td>\n          1472881213\n        <\/td>\n<td>\n          UC Browser\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          &#8230;\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<\/tr>\n<tr>\n<th>\n          4\n        <\/th>\n<td>\n          Organic Search\n        <\/td>\n<td>\n          20160902\n        <\/td>\n<td>\n          27294437909732085\n        <\/td>\n<td>\n          27294437909732085_1472822600\n        <\/td>\n<td>\n          Not Socially Engaged\n        <\/td>\n<td>\n          1472822600\n        <\/td>\n<td>\n          2\n        <\/td>\n<td>\n          1472822600\n        <\/td>\n<td>\n          Chrome\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          &#8230;\n        <\/td>\n<td>\n          not available in demo dataset\n        <\/td>\n<td>\n          True\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<td>\n          NaN\n        <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n    5 rows \u00d7 55 columns\n  <\/p>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\"># converting date column into a proper format\ndef convert_to_datetime(frame):\n    frame['date'] = frame['date'].astype(str)\n    frame['date'] = frame['date'].apply(lambda x : x[:4] + \"-\" + x[4:6] + \"-\" + x[6:])\n    frame['date'] = pd.to_datetime(frame['date'])\n    return frame\n\ndf = convert_to_datetime(df)<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">#converting totals_transactionRevenue into int64 datatype and filling missing values as 0\ndf['totals_transactionRevenue'] = df['totals_transactionRevenue'].fillna(0).astype('int64')<\/code><\/pre>\n<\/div>\n<h2>5&#46; Analysing with data visualization<\/h2>\n<p>To Analyse data we will code different plot using all the existing attributes using multiple libraries like plotly, matplotlib and seaborn.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">#Analysing missing data\ndef missing_plot(frame, set_name, palette):\n    nan_ratio = frame.isna().sum()\/len(frame)\n    nan_ratio = nan_ratio.to_frame().reset_index().rename({'index': 'column', 0: 'Percentage'},axis=1)\n    nan_ratio.sort_values(by=['Percentage'], ascending=False, inplace=True)\n    plt.figure(figsize=(8,6))\n    plt.title(\"% Columns Missing Values\")\n    ax = sns.barplot(x='Percentage', y='column', orient='h',\n                     data=nan_ratio[nan_ratio['Percentage'] > 0],\n                     palette= palette)\n\nmissing_plot(df, 'df', 'Greens_d')<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_30_0.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_30_0.png\" alt=\"\" width=\"715\" height=\"387\" class=\"aligncenter size-full wp-image-28547\" srcset=\"\/wp-content\/uploads\/2022\/07\/output_30_0.png 715w, \/wp-content\/uploads\/2022\/07\/output_30_0-300x162.png 300w, \/wp-content\/uploads\/2022\/07\/output_30_0-600x325.png 600w\" sizes=\"(max-width: 715px) 100vw, 715px\" \/><\/a><\/p>\n<p>Most missing values are in trafficSource.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\"># This plot shows the number of visits for each channel\ndef barplot_percentage(count_feat, color1= 'rgb(55, 83, 109)', \n                       color2= 'rgb(26, 118, 255)',num_bars= None):\n\n    df_channel = 100*df[count_feat].value_counts()\/len(df)\n    df_channel = df_channel.to_frame().reset_index()\n    if num_bars:\n        df_channel = df_channel.head(num_bars)\n\n    trace0 = go.Bar(\n        x=df_channel['index'],\n        y=df_channel[count_feat],\n        name='df set',\n        marker=dict(color=color1)\n    )\n\n\n    layout = go.Layout(\n        title='{} grouping'.format(count_feat),\n        xaxis=dict(\n            tickfont=dict(size=14, color='rgb(107, 107, 107)')\n        ),\n        yaxis=dict(\n            title='Percentage of visits',\n            titlefont=dict(size=16, color='rgb(107, 107, 107)'),\n            tickfont=dict(size=14, color='rgb(107, 107, 107)')\n        ),\n        legend=dict(\n            x=1.0,\n            y=1.0,\n            bgcolor='rgba(255, 255, 255, 0)',\n            bordercolor='rgba(255, 255, 255, 0)'\n        ),\n        barmode='group',\n        bargap=0.15,\n        bargroupgap=0.1\n    )\n\n    fig = go.Figure(data=[trace0], layout=layout)\n    iplot(fig)\nbarplot_percentage('channelGrouping')<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_29.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_29.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" srcset=\"\/wp-content\/uploads\/2022\/07\/Screenshot_29.png 1424w, \/wp-content\/uploads\/2022\/07\/Screenshot_29-300x136.png 300w, \/wp-content\/uploads\/2022\/07\/Screenshot_29-1024x464.png 1024w, \/wp-content\/uploads\/2022\/07\/Screenshot_29-768x348.png 768w, \/wp-content\/uploads\/2022\/07\/Screenshot_29-600x272.png 600w\" sizes=\"(max-width: 1424px) 100vw, 1424px\" \/><\/a><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\"># Now we will analyse the time series data\n\ntmp_df = df['date'].value_counts().to_frame().reset_index().sort_values('index')\ntmp_df = tmp_df.rename(columns = {\"date\" : \"visits\"}).rename(columns = {\"index\" : \"date\"})\n\n# Plot visits\ntrace1 = go.Scatter(x=tmp_df.date.astype(str), y=tmp_df.visits,\n                    opacity = 0.8, line = dict(color = '#ff751a'), name= 'df')\n\ntraces = [trace1]\n\nlayout = dict(\n    title= \"Visits by date\",\n    xaxis=dict(\n        rangeselector=dict(\n            buttons=list([\n                dict(count=1, label='1m', step='month', stepmode='backward'),\n                dict(count=3, label='3m', step='month', stepmode='backward'),\n                dict(count=6, label='6m', step='month', stepmode='backward'),\n                dict(step='all')\n            ])\n        ),\n        rangeslider=dict(visible = True),\n        type='date'\n    )\n)\n\nfig = dict(data= traces, layout=layout)\niplot(fig)\n\n\n# Revenue by time\ndf_date_sum = df.groupby('date')['totals_transactionRevenue'].sum().to_frame().reset_index()\n# Plot\ntrace_date = go.Scatter(x=df_date_sum.date.astype(str), \n                        y=df_date_sum['totals_transactionRevenue'].apply(lambda x: np.log(x)), opacity = 0.8)\nlayout = dict(\n    title= \"Log Revenue by date\",\n    xaxis=dict(\n        rangeselector=dict(\n            buttons=list([\n                dict(count=1, label='1m', step='month', stepmode='backward'),\n                dict(count=3, label='3m', step='month', stepmode='backward'),\n                dict(count=6, label='6m', step='month', stepmode='backward'),\n                dict(step='all')\n            ])\n        ),\n        rangeslider=dict(visible = True),\n        type='date'\n    )\n)\n\nfig = dict(data= [trace_date], layout=layout)\niplot(fig)<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_30.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_30.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" \/><\/a><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_31.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_31.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" \/><\/a><\/p>\n<h2>Analysing Revenue<\/h2>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\"># Flag visits with revenue\ndf['has_revenue'] = df['totals_transactionRevenue'].apply(lambda x: 1 if x > 0 else 0)<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">channel_order = ['Referral', 'Display', 'Paid Search', 'Direct', 'Organic Search', '(Other)', 'Social', 'Affiliates']\nplt.figure(figsize=(10,4))\nplt.title(\"% visits with revenue \/ channel\")\nsns.barplot(x='channelGrouping', y='has_revenue', data=df, order=channel_order, palette='Greens_d')\nrevenue_channel = df.groupby('channelGrouping')['totals_transactionRevenue'].sum()\nrevenue_channel = revenue_channel.to_frame().reset_index()\nplt.figure(figsize=(10,4))\nplt.title(\"Mean revenue \/ channel\")\nax = sns.barplot(x='channelGrouping', y='totals_transactionRevenue', data=revenue_channel, order=channel_order, palette='Greens_d')<\/code><\/pre>\n<\/div>\n<p>[<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_36_0.png\" alt=\"\" width=\"600\" height=\"278\" class=\"aligncenter size-full wp-image-28551\" \/><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_36_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_36_1.png\" alt=\"\" width=\"600\" height=\"278\" class=\"aligncenter size-full wp-image-28551\" srcset=\"\/wp-content\/uploads\/2022\/07\/output_36_1.png 600w, \/wp-content\/uploads\/2022\/07\/output_36_1-300x139.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">df['revenue_status']=df.totals_transactionRevenue.apply(lambda x: 0 if x==0 else 1)\n\n#Revenue generated by different Operating systems\n\ndf_OS=df[['device_operatingSystem','totals_transactionRevenue','revenue_status']].groupby(df.device_operatingSystem).aggregate({'totals_transactionRevenue':['mean'],\n                                                                                                              'revenue_status':['count']}).reset_index()\ndf_OS.columns=['device_operatingSystem','totals_transactionRevenue_mean','revenue_status_count']\ndf1=df_OS.sort_values(by='totals_transactionRevenue_mean',ascending=False)[df_OS.totals_transactionRevenue_mean>0]\ndisplay(df1.style.format(formatter))\n\nplt.subplots(figsize=(20,5))\nplt.subplot(1,2,1)\nplt.title('REVENUE MEAN BY OPERATING SYSTEM',color='b',fontsize=12)\nplt.xlabel('Operating Systems',color='b',fontsize=12)\nplt.ylabel('Mean Revenue',color='b',fontsize=12)\nplt.bar(range(len(df1)),df1.totals_transactionRevenue_mean,color='grey')\nplt.xticks(range(len(df1)),df1.device_operatingSystem,rotation=90,fontsize=12)\nplt.yticks(fontsize=12)\n\n\nplt.subplot(1,2,2)\nplt.title('NUMBER OF TRANSACTIONS WITH REVENUE BY OPERATING SYSTEM',color='b',fontsize=12)\nplt.xlabel('Operating Systems',color='b',fontsize=12)\nplt.ylabel('Count of Transactions with Revenue',color='b',fontsize=12)\nplt.bar(range(len(df1)),df1.revenue_status_count,color='orange')\nplt.yticks(fontsize=12)\nplt.xticks(range(len(df1)),df1.device_operatingSystem,rotation=90,fontsize=12)\nplt.show()<\/code><\/pre>\n<\/div>\n<p><style type=\"text\/css\">\n<\/style>\n<\/p>\n<table id=\"T_f34ae_\">\n<thead>\n<tr>\n<th class=\"blank level0\">\n        \u00a0\n      <\/th>\n<th class=\"col_heading level0 col0\">\n        device_operatingSystem\n      <\/th>\n<th class=\"col_heading level0 col1\">\n        totals_transactionRevenue_mean\n      <\/th>\n<th class=\"col_heading level0 col2\">\n        revenue_status_count\n      <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th id=\"T_f34ae_level0_row0\" class=\"row_heading level0 row0\">\n        3\n      <\/th>\n<td id=\"T_f34ae_row0_col0\" class=\"data row0 col0\">\n        Chrome OS\n      <\/td>\n<td id=\"T_f34ae_row0_col1\" class=\"data row0 col1\">\n        6984005.39\n      <\/td>\n<td id=\"T_f34ae_row0_col2\" class=\"data row0 col2\">\n        26337\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row1\" class=\"row_heading level0 row1\">\n        7\n      <\/th>\n<td id=\"T_f34ae_row1_col0\" class=\"data row1 col0\">\n        Macintosh\n      <\/td>\n<td id=\"T_f34ae_row1_col1\" class=\"data row1 col1\">\n        3372381.41\n      <\/td>\n<td id=\"T_f34ae_row1_col2\" class=\"data row1 col2\">\n        253938\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row2\" class=\"row_heading level0 row2\">\n        6\n      <\/th>\n<td id=\"T_f34ae_row2_col0\" class=\"data row2 col0\">\n        Linux\n      <\/td>\n<td id=\"T_f34ae_row2_col1\" class=\"data row2 col1\">\n        1253365.30\n      <\/td>\n<td id=\"T_f34ae_row2_col2\" class=\"data row2 col2\">\n        35034\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row3\" class=\"row_heading level0 row3\">\n        16\n      <\/th>\n<td id=\"T_f34ae_row3_col0\" class=\"data row3 col0\">\n        Windows\n      <\/td>\n<td id=\"T_f34ae_row3_col1\" class=\"data row3 col1\">\n        1134945.73\n      <\/td>\n<td id=\"T_f34ae_row3_col2\" class=\"data row3 col2\">\n        350072\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row4\" class=\"row_heading level0 row4\">\n        1\n      <\/th>\n<td id=\"T_f34ae_row4_col0\" class=\"data row4 col0\">\n        Android\n      <\/td>\n<td id=\"T_f34ae_row4_col1\" class=\"data row4 col1\">\n        293330.32\n      <\/td>\n<td id=\"T_f34ae_row4_col2\" class=\"data row4 col2\">\n        123892\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row5\" class=\"row_heading level0 row5\">\n        19\n      <\/th>\n<td id=\"T_f34ae_row5_col0\" class=\"data row5 col0\">\n        iOS\n      <\/td>\n<td id=\"T_f34ae_row5_col1\" class=\"data row5 col1\">\n        205887.71\n      <\/td>\n<td id=\"T_f34ae_row5_col2\" class=\"data row5 col2\">\n        107665\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_f34ae_level0_row6\" class=\"row_heading level0 row6\">\n        17\n      <\/th>\n<td id=\"T_f34ae_row6_col0\" class=\"data row6 col0\">\n        Windows Phone\n      <\/td>\n<td id=\"T_f34ae_row6_col1\" class=\"data row6 col1\">\n        21710.53\n      <\/td>\n<td id=\"T_f34ae_row6_col2\" class=\"data row6 col2\">\n        1216\n      <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_37_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_37_1.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" \/><\/a><\/p>\n<h2>Revenue generated by different Browsers<\/h2>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\ndf_browser=df[['device_browser','totals_transactionRevenue','revenue_status']].groupby(df.device_browser).aggregate({'totals_transactionRevenue':['mean'],\n                                                                                                              'revenue_status':['count']}).reset_index()\ndf_browser.columns=['device_browser','totals_transactionRevenue_mean','revenue_status_count']\ndf1=df_browser.sort_values(by='totals_transactionRevenue_mean',ascending=False)[df_browser.totals_transactionRevenue_mean>0]\nformatter = {'totals_transactionRevenue_mean':'{:4.2f}'}\ndisplay(df1.style.format(formatter))\n\nplt.subplots(figsize=(20,5))\nplt.subplot(1,2,1)\nplt.title('REVENUE MEAN BY BROWSER',color='b',fontsize=12)\nplt.xlabel('Browsers',color='b',fontsize=12)\nplt.ylabel('Mean Revenue',color='b',fontsize=12)\nplt.bar(range(len(df1)),df1.totals_transactionRevenue_mean,color='grey')\nplt.xticks(range(len(df1)),df1.device_browser,rotation=90,fontsize=12)\nplt.yticks(fontsize=12)\n\n\nplt.subplot(1,2,2)\nplt.title('NUMBER OF TRANSACTIONS WITH REVENUE BY BROWSER',color='b',fontsize=12)\nplt.xlabel('Browsers',color='b',fontsize=12)\nplt.ylabel('Count of Transactions with Revenue',color='b',fontsize=12)\nplt.bar(range(len(df1)),df1.revenue_status_count,color='orange')\nplt.xticks(range(len(df1)),df1.device_browser,rotation=90,fontsize=12)\nplt.yticks(fontsize=12)\nplt.show()\n<\/code><\/pre>\n<\/div>\n<p><style type=\"text\/css\">\n<\/style>\n<\/p>\n<table id=\"T_0fe27_\">\n<thead>\n<tr>\n<th class=\"blank level0\">\n        \u00a0\n      <\/th>\n<th class=\"col_heading level0 col0\">\n        device_browser\n      <\/th>\n<th class=\"col_heading level0 col1\">\n        totals_transactionRevenue_mean\n      <\/th>\n<th class=\"col_heading level0 col2\">\n        revenue_status_count\n      <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th id=\"T_0fe27_level0_row0\" class=\"row_heading level0 row0\">\n        16\n      <\/th>\n<td id=\"T_0fe27_row0_col0\" class=\"data row0 col0\">\n        Firefox\n      <\/td>\n<td id=\"T_0fe27_row0_col1\" class=\"data row0 col1\">\n        2409461.27\n      <\/td>\n<td id=\"T_0fe27_row0_col2\" class=\"data row0 col2\">\n        37069\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row1\" class=\"row_heading level0 row1\">\n        11\n      <\/th>\n<td id=\"T_0fe27_row1_col0\" class=\"data row1 col0\">\n        Chrome\n      <\/td>\n<td id=\"T_0fe27_row1_col1\" class=\"data row1 col1\">\n        2229505.52\n      <\/td>\n<td id=\"T_0fe27_row1_col2\" class=\"data row1 col2\">\n        620364\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row2\" class=\"row_heading level0 row2\">\n        15\n      <\/th>\n<td id=\"T_0fe27_row2_col0\" class=\"data row2 col0\">\n        Edge\n      <\/td>\n<td id=\"T_0fe27_row2_col1\" class=\"data row2 col1\">\n        635273.89\n      <\/td>\n<td id=\"T_0fe27_row2_col2\" class=\"data row2 col2\">\n        10205\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row3\" class=\"row_heading level0 row3\">\n        20\n      <\/th>\n<td id=\"T_0fe27_row3_col0\" class=\"data row3 col0\">\n        Internet Explorer\n      <\/td>\n<td id=\"T_0fe27_row3_col1\" class=\"data row3 col1\">\n        426092.90\n      <\/td>\n<td id=\"T_0fe27_row3_col2\" class=\"data row3 col2\">\n        19375\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row4\" class=\"row_heading level0 row4\">\n        40\n      <\/th>\n<td id=\"T_0fe27_row4_col0\" class=\"data row4 col0\">\n        Safari\n      <\/td>\n<td id=\"T_0fe27_row4_col1\" class=\"data row4 col1\">\n        287511.21\n      <\/td>\n<td id=\"T_0fe27_row4_col2\" class=\"data row4 col2\">\n        182245\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row5\" class=\"row_heading level0 row5\">\n        3\n      <\/th>\n<td id=\"T_0fe27_row5_col0\" class=\"data row5 col0\">\n        Amazon Silk\n      <\/td>\n<td id=\"T_0fe27_row5_col1\" class=\"data row5 col1\">\n        53458.11\n      <\/td>\n<td id=\"T_0fe27_row5_col2\" class=\"data row5 col2\">\n        561\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row6\" class=\"row_heading level0 row6\">\n        36\n      <\/th>\n<td id=\"T_0fe27_row6_col0\" class=\"data row6 col0\">\n        Opera\n      <\/td>\n<td id=\"T_0fe27_row6_col1\" class=\"data row6 col1\">\n        38162.33\n      <\/td>\n<td id=\"T_0fe27_row6_col2\" class=\"data row6 col2\">\n        5643\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row7\" class=\"row_heading level0 row7\">\n        41\n      <\/th>\n<td id=\"T_0fe27_row7_col0\" class=\"data row7 col0\">\n        Safari (in-app)\n      <\/td>\n<td id=\"T_0fe27_row7_col1\" class=\"data row7 col1\">\n        22448.18\n      <\/td>\n<td id=\"T_0fe27_row7_col2\" class=\"data row7 col2\">\n        6850\n      <\/td>\n<\/tr>\n<tr>\n<th id=\"T_0fe27_level0_row8\" class=\"row_heading level0 row8\">\n        6\n      <\/th>\n<td id=\"T_0fe27_row8_col0\" class=\"data row8 col0\">\n        Android Webview\n      <\/td>\n<td id=\"T_0fe27_row8_col1\" class=\"data row8 col1\">\n        14602.67\n      <\/td>\n<td id=\"T_0fe27_row8_col2\" class=\"data row8 col2\">\n        7865\n      <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_38_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_38_1.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" \/><\/a><\/p>\n<h2>Analysing multiple attributes as per different location<\/h2>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">def plotmap(frame, z_var, countries_col, title, colorscale, rcolor=True):\n\n    data = [ dict(\n            type = 'choropleth',\n            autocolorscale = False,\n            colorscale = colorscale,\n            showscale = True,\n            reversescale = rcolor,\n            locations = frame[countries_col],\n            z = frame[z_var],\n            locationmode = 'country names',\n            text = frame[countries_col],\n            marker = dict(line = dict(color = '#fff', width = 2))\n        )           \n    ]\n\n    layout = dict(\n        height=680,\n        #width=1200,\n        title = title,\n        geo = dict(\n            showframe = False,\n            showcoastlines = False,\n            projection = dict(type = 'mercator'),\n        ),\n    )\n    fig = dict(data=data, layout=layout)\n    iplot(fig)\n\ncolorscale = [[0, 'rgb(102,194,165)'], [0.005, 'rgb(102,194,165)'], \n              [0.01, 'rgb(171,221,164)'], [0.02, 'rgb(230,245,152)'], \n              [0.04, 'rgb(255,255,191)'], [0.05, 'rgb(254,224,139)'], \n              [0.10, 'rgb(253,174,97)'], [0.25, 'rgb(213,62,79)'], [1.0, 'rgb(158,1,66)']]\n    \n# Plot world map - total visits\ntmp = df[\"geoNetwork_country\"].value_counts().to_frame().reset_index()\nplotmap(tmp, 'geoNetwork_country', 'index', 'Total visits by Country', colorscale, False)\n\ncolorscale = [[0,\"rgb(5, 10, 172)\"],[0.35,\"rgb(40, 60, 190)\"],[0.5,\"rgb(70, 100, 245)\"],\n        [0.6,\"rgb(90, 120, 245)\"],[0.7,\"rgb(106, 137, 247)\"],[1,\"rgb(220, 220, 220)\"]]\n\n# Plot world map - total revenue\ntmp = df.groupby(\"geoNetwork_country\").agg({\"totals_transactionRevenue\" : \"sum\"}).reset_index()\nplotmap(tmp, 'totals_transactionRevenue','geoNetwork_country', 'Total revenue by country', colorscale)<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_35.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_35.png\" alt=\"\" width=\"1665\" height=\"982\" class=\"aligncenter size-full wp-image-28562\" srcset=\"\/wp-content\/uploads\/2022\/07\/Screenshot_35.png 1665w, \/wp-content\/uploads\/2022\/07\/Screenshot_35-300x177.png 300w, \/wp-content\/uploads\/2022\/07\/Screenshot_35-1024x604.png 1024w, \/wp-content\/uploads\/2022\/07\/Screenshot_35-768x453.png 768w, \/wp-content\/uploads\/2022\/07\/Screenshot_35-1536x906.png 1536w, \/wp-content\/uploads\/2022\/07\/Screenshot_35-600x354.png 600w\" sizes=\"(max-width: 1665px) 100vw, 1665px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_36.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_36.png\" alt=\"\" width=\"1646\" height=\"889\" class=\"aligncenter size-full wp-image-28563\" srcset=\"\/wp-content\/uploads\/2022\/07\/Screenshot_36.png 1646w, \/wp-content\/uploads\/2022\/07\/Screenshot_36-300x162.png 300w, \/wp-content\/uploads\/2022\/07\/Screenshot_36-1024x553.png 1024w, \/wp-content\/uploads\/2022\/07\/Screenshot_36-768x415.png 768w, \/wp-content\/uploads\/2022\/07\/Screenshot_36-1536x830.png 1536w, \/wp-content\/uploads\/2022\/07\/Screenshot_36-600x324.png 600w\" sizes=\"(max-width: 1646px) 100vw, 1646px\" \/><\/a><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\"># Using squarify to plot an interesting distribution\ndf.loc[df[\"geoNetwork_city\"] == \"not available in demo dataset\", 'geoNetwork_city'] = np.nan\nnumber_of_colors = 20 \ncolor = [\"#\"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])\n             for i in range(number_of_colors)]\n\ncity_tree = df[\"geoNetwork_city\"].value_counts() #counting \n\nprint(\"Description most frequent Citys: \" )\nprint(city_tree[:15])\n\ncity_tree = round((city_tree[:30] \/ len(df['geoNetwork_city']) * 100),2)\n\nplt.figure(figsize=(14,5))\ng = squarify.plot(sizes=city_tree.values, label=city_tree.index, \n                  value=city_tree.values,\n                  alpha=.4, color=color)\ng.set_title(\"'TOP 30 Citys - % size of total\",fontsize=20)\ng.set_axis_off()\nplt.show()<\/code><\/pre>\n<\/div>\n<pre><code>    Description most frequent Cities: \n    Mountain View       40884\n    (not set)           34262\n    New York            26371\n    San Francisco       20329\n    Sunnyvale           13086\n    London              12607\n    San Jose            10295\n    Los Angeles          8670\n    Bangkok              7709\n    Chicago              7444\n    Ho Chi Minh City     7342\n    Istanbul             6330\n    Bengaluru            5468\n    Toronto              5223\n    Hanoi                5032\n    Name: geoNetwork_city, dtype: int64\n<\/code><\/pre>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_41_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_41_1.png\" alt=\"\" width=\"1424\" height=\"645\" class=\"aligncenter size-full wp-image-28556\" \/><\/a><\/p>\n<p>Nicely distributed clients that accessed the store. The top 5 cities are:<\/p>\n<p>Mountain View, New York, San Francisco, Sunnyvale, London &#96;<code><\/code><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">barplot_percentage('geoNetwork_networkDomain', num_bars= 10, \n                   color1='rgb(38, 115, 77)', color2='rgb(102, 204, 153)')<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_38.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/Screenshot_38.png\" alt=\"\" width=\"1646\" height=\"889\" class=\"aligncenter size-full wp-image-28563\" \/><\/a><\/p>\n<p>Let&#8217;s analyse the Device Category<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">plt.figure(figsize=(14,5))\n\nplt.subplot(1,2,1)\nsns.countplot(df[\"device_deviceCategory\"], palette=\"hls\") \nplt.title(\"Device Category Count\", fontsize=10)\nplt.xlabel(\"Category\", fontsize=12) \nplt.ylabel(\"Count\", fontsize=12) \nplt.xticks(fontsize=10)\n\nplt.subplot(1,2,2)\nsns.boxenplot(x=\"device_deviceCategory\", y = 'totals_transactionRevenue', \n              data=df[df['totals_transactionRevenue'] > 0], palette=\"hls\")\nplt.title(\"Device Category Revenue Distribuition\", fontsize=10)\nplt.xlabel(\"Category\", fontsize=12) \nplt.ylabel(\"Revenue(Log)\", fontsize=12) \nplt.xticks(fontsize=10) \n\nplt.subplots_adjust(hspace = 0.9, wspace = 0.5)\n\nplt.show() <\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_45_0.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/07\/output_45_0.png\" alt=\"\" width=\"1646\" height=\"889\" class=\"aligncenter size-full wp-image-28563\" \/><\/a><\/p>\n<p>desktop represents 73.5%, mobile represents 23.12%, and tablet represents 3.38%<\/p>\n<h2>6&#46; Conclusion<\/h2>\n<p>In this tutorial we analysed and explored customer purchasing data using Python and GridDB. We examined two ways to import our data, using (1) GridDB and (2) Pandas. For large datasets, GridDB provides an excellent alternative to import data in your notebook as it is open-source and highly scalable.<\/p>\n<p><a href=\"https:\/\/github.com\/griddbnet\/Blogs\/blob\/exploring_consumer_purchases\/Exploring%20Consumer%20Purchases%20Patterns%20using%20GridDB%20and%20Python\/Exploring%20Consumer%20Purchases%20Patterns%20using%20GridDB%20and%20Python.ipynb\"> Full Jupyter File found here <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer follows his or her own set of buying patterns. By recognizing, analyzing, and measuring buying patterns, businesses can gain a better understanding of their target audience and potentially expand their reach. The repo for this blog [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":28225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-19T07:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:56:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1707\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Exploring Consumer Purchases Patterns using GridDB and Python\",\"datePublished\":\"2022-08-19T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\"},\"wordCount\":1321,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\",\"name\":\"Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg\",\"datePublished\":\"2022-08-19T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:09+00:00\",\"description\":\"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg\",\"contentUrl\":\"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg\",\"width\":2560,\"height\":1707},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/www.griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT","description":"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/","og_locale":"en_US","og_type":"article","og_title":"Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT","og_description":"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer","og_url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2022-08-19T07:00:00+00:00","article_modified_time":"2025-11-13T20:56:09+00:00","og_image":[{"width":2560,"height":1707,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#article","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Exploring Consumer Purchases Patterns using GridDB and Python","datePublished":"2022-08-19T07:00:00+00:00","dateModified":"2025-11-13T20:56:09+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/"},"wordCount":1321,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/","name":"Exploring Consumer Purchases Patterns using GridDB and Python | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg","datePublished":"2022-08-19T07:00:00+00:00","dateModified":"2025-11-13T20:56:09+00:00","description":"Understanding consumer behavior is important because it assists marketers in understanding what motivates consumers to make purchases. Each consumer","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/exploring-consumer-purchases-patterns-using-griddb-and-python\/#primaryimage","url":"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg","contentUrl":"\/wp-content\/uploads\/2022\/04\/ecommerce-buying-on-a-mac_2560x1707.jpg","width":2560,"height":1707},{"@type":"WebSite","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/www.griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46717"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46717\/revisions"}],"predecessor-version":[{"id":51389,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46717\/revisions\/51389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media\/28225"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}