Author name: cndro

Blogs

How to Create and Use Sets in Tableau: Types and Examples

                                                                                                                       Photo by Clay Banks on Unsplash Tableau Sets are used to create subsets of data based on certain conditions defined by the user. It allows you to pick specific segments of a dimension that will generate insights in your data. We can create Sets for just about anything based on quantitative thresholds. A perfect example of why Sets are used is when we want to compare insight from a part of our data, we can accomplish this with a Set. We can do that by selecting our column of interest to make a subset and selecting only a few details we need. Implementing Sets in our dashboard makes it more interactive for the audience. Now, let’s discuss the two types of sets we have and how to create them. Types of Tableau Sets Dynamic Sets Fixed Sets Dynamic Sets: Just as the name suggests, it’s very dynamic, whereby when the value in the dynamic sets changes, the underlying data also changes. This dynamic Set is usually based on a single dimension. How to Create Dynamic Sets Follow each step below to create a Dynamic set in Tableau Desktop. Step 1: Open your Tableau Desktop and bring in the Sample Superstore Dataset, which we will use for demonstration. Step 2: Now, let’s create a Set. Go to your Data Pane, Select the Customer Name Dimensions and click on Create → Set. Step 3: In the “Create Set” window, we have three ways to customize our Set. Let’s discuss this below ; General: The General tab gives users a list of options to select required values from. These selected values will be used in our Set. We can also select the “Use All” option to consider all values always, even when new values are being added or removed. Condition: We also have the condition tab, which we can use to define conditions that determine what values to include in the Set. In the image below, we applied a condition of having values where our Sales is greater than $10,000. Top: Now, the third way of customizing our Set is by using the “Top” tab. The Top tab is used for selecting only specified ’N’ number of top or bottom values. For instance, we can apply a condition of having top 10 customers based on profits, as we have below. Now that we’ve seen how we can create Dynamic Sets, let’s discuss the Fixed Sets and how we can also create them. Fixed Sets: Fixed sets can either be single-dimensional or multi-dimensional. They are sets that do not change and we can create this Set by following the steps listed below; Step 1: Draw a Scatter chat using Profit and Sales. Step 2: In the chart, we’ll select any area(one or more scatter dots) we’re interested in creating a set with. After you’ve highlighted the area, you Right Click and select Create Set. Step 3: Enter the Set’s name in the dialog box and click ok. You should have your Set in the Pane. And that’s how to create Sets in Tableau. Follow the steps above to get started. Hope you found this post helpful. If you do, share and follow for more posts.

Blogs

Automate Your WhatsApp Messages with Python in Minutes

                                                                                                   Photo by Christian Wiediger on Unsplash In this tutorial, we’ll learn how to automate WhatsApp messages with Python programming language. Python, as we know, is a very flexible language utilized by Developers daily in performing different tasks ranging from website and software development to task automation, data analysis, data visualization, game development, embedded applications, and many more. We want to automate our tasks; implementing this will make life easier. We don’t have to be bothered about forgetting to send messages to our loved ones, especially on their Birthdays or any other urgent messages. With Python, we can easily automate our message to be sent at our desired time. The Python library we’ll use in this project is Pywhatkit, a library used for sending WhatsApp messages. It has a lot of dependencies, and various WhatsApp features like sending images and gifs to personal contact or even a group chat. Now, let’s see how we can use this library. This implementation will be done in a step-by-step process. Step 1: Set up a Virtual Environment The first thing we need to do is to set up a virtual environment for our project. We do that to keep our dependencies isolated, whereby we don’t break our system tools. Note: A windows machine is used in implementing this project. 1 #If you don’t have virtualenv you can install with the command 2 pip install virtualenv 3 4 #Create the virtaul environment 5 virtualenv mypython 6 7 #Activate the Virtual Environemt 8 mypthon\Scripts\activate   Step 2: Install Pywhatkit After you’ve activated your virtual environment, what we do next is install the Pywhatkit Library and flask by using the command below; 1 pip install pywhatkit 2 pip install flask   Step 3: Send Message to WhatsApp Contact Here, we’ll demonstrate how to send a message to a particular contact on our WhatsApp App. Before going into that, you must log in to your WhatsApp account using WhatsApp Web. You can use this address WhatsApp Web on your Chrome Desktop. Here is a code to demonstrate how to send our message in seconds. We used the .sendwhatmsg endpoint to pass in our arguments. The first argument, “+xxxxxxxx “is telling us what contact number we want to send our message to, while the “This is our xxxxxx “is the message body we want to send. This “13” is the time in hours, while the next number is time in minutes, and the next one is the time in seconds. The “True” argument indicates we want our WhatsApp tab to be closed automatically in our browser after the message has been delivered. The last argument is the time we want the tab closed in seconds. 1 #import the library 2 import pywhatkit 3 #pass in your arguments here 4 pywhatkit.sendwhatmsg(“+xxxxxxxxx”, “This is our first demo text message with python”, 13, 15, 10, True, 2   Step 4: Send Message to WhatsApp Group We can also send messages to a group chat in Python; to do that, we need the “id” of the group. This will be used in place of a number. You can get the id of your group by clicking the group info → scroll down and click on the invite via link → click on the copy link. Now you will extract the suffix part of the link, which will be the id to use in the code. 1 #import the library 2 import pywhatkit 3 #pass in your arguments here 4 pywhatkit.sendwhatmsg_to_group(“your group id”, “This is our first demo text message with python”, 13, 20, 10, True, 2)   Step 5: Send Images To WhatsApp Contact & Groups You may also want to share images with your contact or group. We can do that using the code below. 1 #import the library 2 import pywhatkit 3 # Send an Image to a Group with the Caption “Check out this image” 4 pywhatkit.sendwhats_image(“your group id”, “Images/Hello.png”, “Check out this image”) 5 6 # Send an Image to your contact with the no Caption 7 pywhatkit.sendwhats_image(“+xxxxxxxxxxx”, “Images/Hello.png”)   Wow! You created your own powerful, database-driven WhatsApp automation tool. To really appreciate Python’s simplicity, you must now give it a try. Hope you enjoyed this post. Thanks for reading.

Blogs

How to Convert Speech to Text in Python

In this tutorial, we’ll learn how to convert speech or an audio file to text format. This very interesting topic has been utilized in different ways such as Business, Content Creation, Bots, and lots more. The Speech Recognition library is an essential library to discuss whenever we’re looking into speech-to-text. Python supports many speech recognition engines and APIs, including the Google Speech Engine, Google Cloud Speech API, IBM Speech to Text, and lots more. Speech recognition can be broken down into three stages: Automatic speech recognition (ASR): This performs the task of transcribing the audio file. Natural language processing (NLP): It works on deriving meaning from the speech data and each text converted. Text-to-speech (TTS): This converts text to human-like speech. Our primary focus here is how we can convert speech to text. We’ll demonstrate in a step-by-step process. Step 1: Install Libraries Here, we’ll install all essential libraries we need in our code to convert speech or audio file to text. The first library we need to install is the Python Speech Recognition Module. We can install it with the command below; 1 pip install speechrecognition   The next library to install is the Pydub library which is very useful for manipulating audio files. You can install it with this command; 1 pip install pydub The last one to install is the Pyaudio Library, which we can install with the command below; 1 pip install pyaudio Step 2: Convert Speech to Text In this code, we’ll use the Speech recognition library to gain access to our Microphone, whereby we’ll speak and this will be converted to text here. The code we used for demonstrating is shown below; 1 #import Library 2 import speech_recognition as sr 3 4 # this will be used to get audio from the microphone 5 v = sr.Recognizer() 6 #Here, we represent our microphone as source 7 with sr.Microphone() as source: 8 print(“Speak:”) 9 #This is where it listens to our speech before going further to recognize it 10 the_audio = v.listen(source) 11 12 try: 13 print(“Your Speech was:” + v.recognize_google(the_audio)) 14 except sr.UnknownValueError: 15 print(“Could not understand audio”)   Output Step 3: Convert Audio Files to Text We converted our speech to text from what we did in the earlier step, but here we will work with an Audio file. To work with our Demo Audio, we’ll use the Pydub library we installed earlier to break our file into smaller pieces. We usually do that for a long Audio file to make the speech recognition library listen well and return accurate text format. The code used is shown below; 1 #we import our libraries here 2 from pydub import AudioSegment 3 from pydub.utils import make_chunks 4 import os 5 import speech_recognition as sr 6 import warnings 7 warnings.filterwarnings(“ignore”) 8 9 def process_audio(filename): 10 #We open a text file here to write in our Audio file that has been converted to text 11 txtf = open(“the_audio.txt”, “w+”) 12 #we use the AudioSegment to open our audio file, this file is in .wav format 13 myaudio = AudioSegment.from_wav(filename) 14 #we specify our chunk length we want to use 15 chunks_length_ms = 7000 16 chunks = make_chunks(myaudio, chunks_length_ms) 17 #Here, we loop through our chunk object, which we already pass our Audio file in and the length 18 for i, chunk in enumerate(chunks): 19 #we save this chunked file individually in a folder in same wav format 20 chunkName = ‘./chunked/’+filename+”_{0}.wav”.format(i) 21 print(‘I am exporting’, chunkName) 22 chunk.export(chunkName, format=”wav”) 23 #From here, we pass in the file individually to be recognized via speech recognition library 24 file = chunkName 25 #we assign an object method from the speech recognition library 26 r = sr.Recognizer() 27 #We make use of the speech recognition library here, listening to each of our files 28 with sr.AudioFile(file) as source: 29 audio_listened = r.listen(source) 30 try: 31 #Here it tries to recognize and convert to text 32 rec = r.recognize_google(audio_listened) 33 #Now, we use our earlier text file we opened and pass in the result of our conversion inside 34 txtf.write(rec+”.”) 35 #This handles error incase, the speech recognition library doesn’t understand your audio 36 except sr.UnknownValueError: 37 print(“I don’t recognize your audio”) 38 except sr.RequestError as e: 39 print(“could not get the result.check your internet”) 40 #we created a folder where all those Audio files broken down will be saved 41 try: 42 os.makedirs(“chunked”) 43 except: 44 pass 45 46 #we call our function here 47 48 process_audio(“hello.wav”) 49 50 51   Follow the steps we highlighted above to start converting your speech to text in Python. Thanks for reading.

Blogs

How to Read Data from API in Power BI

                                                             Photo by Markus Spiske on Unsplash This tutorial will discuss how to read data from API with Power BI. This will be demonstrated step-by-step by bringing in your data and representing it in a tabular form before plotting your visualization. Before going into that, let’s discuss the API and how it works. Application Programming Interface is a server we can use to retrieve and send data using a code, or we can also say it’s a set of programming code that enables data transmission between one software product and another. An API can either be Private or Public(Open). When an API is private, it is only accessible to Developers and users within an organization. Also, when an API is public, external Developers or users have easy access to information available. Good examples of public APIs are; The Google Map API, News API, Weather Forecast API, and lots more. Also, it is excellent to know that API servers send in their responses in JSON format which means you must know to handle your data and extract them neatly. HTTP Methods In Knowing what actions to perform on the Web Service’s resources, the REST APIs usually listen for HTTP methods which are GET, POST, and DELETE. This HTTP method instructs the API on how to handle the resource. Now that we have a good knowledge of what an API is, we can go move further to discuss how we can connect to API with Power BI. Connect to API with Power BI We will use the Open Air Quality (OpenAQ) Api in our Power BI. This API can be found here, and we will use the countries endpoint. Let’s follow the steps below to see how to connect with API in Power BI. Step 1 Open your Power BI Desktop and click Get Data → Web as shown below; Step 2: After you’ve selected the Web, a new window will come up. Here you will see two radio buttons (Basic and Advanced Option). You will select the Advanced button and configure the task. In the URL parts, put the complete URL of the API you want to work with. You can also add a command timeout and a Request header. These are both optional, though. After you’ve done that, click on OK. Step 3 After you’ve selected OK, it opens a new page which is more of an anonymous authentication for connecting. Select the endpoint you want, and click on Connect to bring your data in. Step 4 Your data should be in tabular form, as shown below. For cases whereby your data isn’t in the proper format, you can use Power BI Query Editor to transform your data into your desired format. And that’s how to read data from API with Power BI. Hope you found it helpful; let’s know in the comments section below. Thanks for reading.

Blogs

Why Storytelling in Data Analysis is Important

                                                Photo by Dmitry Ratushny on Unsplash Storytelling with data is one of the effective skills a Data Scientist or Data Analyst must possess. This is simply the act of communicating insights and patterns in data using the data combination, visual or narrative form. Whenever Data Scientist works with a data, his ability to produce high-quality story is crucial. While not just that, forming opinions and arguments about the data is also essential in making key business decisions. Now, let’s discuss why this is a must-have skill for everyone. Why Storytelling with Data is Important With the amount of data available to us, only data storytelling can give human knowledge what the data connotes and some form of coherence. With a compelling story behind the data, we can engage people’s emotions and intellects by creating a deeper understanding of what they need to know. A good example we can relate to is a weather forecaster who provides weather reports. He also issues advanced warnings for potentially severe weathers and hurricanes. Without him providing the viewers an interactive graphics or visuals, there is no way many could have understood his report. It would mean that storytelling on his part was inadequate. These and many numerous reasons are why many organizations put a lot of efforts into data visualization and storytelling because it prevents them from making bad decisions in business. Also, on the part of the Data Scientist, lack of Storytelling reduces the quality of his work which makes decision making a guessing game. Let’s move further and discuss how exactly we can carry out an effective Storytelling for our Data. How to Do Effective Data Storytelling Understand your Audience The major key thing to always consider is the audience we are working with. We must know what they want and the goal/target that needs to be reached. This is also telling us that the inference generated in a data or let’s say a visualization Dashboard communicates well-detailed information to the audience whereby they understand what the content is and also meet up with their business demand. Make Sure your Story is Concise and Transparent When working with your data, you must have a deeper understanding of what you want to do, having that, communicating your result will be much easier. This result must be concise which means you have a well detailed information in few words. The result also has to be transparent enough for the Audience whereby giving them clear necessary details they need. Understand the Whys When communicating your result to the audience, you must understand the whys; this means you must be able to explain factors responsible for market rising and falling in your data. You can also make this interactive by producing numbers in your data which will make your findings solid. Ensure your Story is Clear When presenting to your audience, you also need to be very clear. You should be able to express yourself in a layman’s language which isn’t too technical for them to understand. You also need to be well engaging so that the information you are giving to them can be memorable. Ensure your Story has a Significant Context The context we mentioned here is a very key point all Data Scientist must not do without. Working with context is what builds value from insights generated. This means the result generated provides a sense of clarity and every essential information required. Hope you enjoyed this post. If you do, give it a clap, share, and follow for more educative posts. Thanks for reading.

Blogs

Predict Customers Churn with TabPy

                                                                     Photo by Headway on Unsplash Customer churn is a common problem across businesses in many sectors. If you want to grow as a company, you have to invest in acquiring new customers. So, whenever a customer leaves, it’s a significant loss. This means as a business owner you have to invest time and effort in replacing them. The ability to predict when a customer is likely to leave is very important, which is why churn analytics enables organizations to identify and analyze the factors influencing customer churn. Here, we will use Telco Customer Churn dataset to build a machine learning model, which will be used in TabPy for making our predictions. Let’s get started; Step1: Installation You need to have Anaconda on your machine, if you don’t. You can download with the steps below; Visit Anaconda.com/downloads Select Windows Download the .exe installer Open and run the .exe installer Open the Anaconda Prompt and run some Python code to test Step2: Install TabPy & Connect with Tableau Desktop Install TabPy on your Machine and connect with Tableau Desktop; you can visit our previous tutorial on how to do that. Step3: Building the Model Here, our model will be built based on any supervised learning approach model, whereby with our training data , the model gets to capture the relationship between our features and target. We trained our model using Logistic Regression Algorithm. The code is shown below; 1 import pandas as pd 2 import numpy as np 3 import seaborn as sns 4 from matplotlib import pyplot as plt 5 df = pd.read_csv(‘WA_Fn-UseC_-Telco-Customer-Churn.csv’) 6 df.head() 7 df.info() 8 df.describe() 9 df.drop(‘customerID’, axis=1, inplace=True) 10 df.head() 11 df.columns = df.columns.str.lower().str.replace(‘ ‘, ‘_’) 12 df.churn = (df.churn == ‘Yes’).astype(int) 13 df_encoding= pd.get_dummies(df, drop_first=True) 14 categorical = [‘gender’, ‘seniorcitizen’, ‘partner’, ‘dependents’, 15 ‘phoneservice’, ‘multiplelines’, ‘internetservice’, 16 ‘onlinesecurity’, ‘onlinebackup’, ‘deviceprotection’, 17 ‘techsupport’, ‘streamingtv’, ‘streamingmovies’, 18 ‘contract’, ‘paperlessbilling’, ‘paymentmethod’] 19 numerical = [‘tenure’, ‘monthlycharges’, ‘totalcharges’] 20 X = df_encoding.drop(‘churn’, axis=1) 21 # Target 22 y = df_encoding[‘churn’] 23 from sklearn.model_selection import train_test_split 24 X_train_full, X_test, y_train_full, y_test = train_test_split(X, y, test_size=0.2, random_state=1) 25 X_train, X_valid, y_train, y_valid = train_test_split(X_train_full, y_train_full, test_size=0.2, random_state=1) 26 print(“Training Data Size: “, len(y_train)) 27 print(“Validation Data Size: “, len(y_valid)) 28 print(“Testing Data Size: “, len(y_test)) 29 from sklearn.linear_model import LogisticRegression 30 model = LogisticRegression(solver=’liblinear’, random_state=1) 31 model.fit(X_train, y_train) 32 y_val_pred = model.predict_proba(X_valid) 33 y_test_pred = model.predict_proba(X_test) 34 y_test_pred 35 print(‘LogisticRegression Training Accuracy: ‘, round(model.score(X_train, y_train), 2)) 36 print(‘LogisticRegression Validation Accuracy: ‘, round(model.score(X_valid, y_valid), 2)) 37 print(‘LogisticRegression Testing Accuracy: ‘, round(model.score(X_test, y_test), 2))   We were able to generate these scores: 1 array([[0.93961448, 0.06038552], 2 [0.92559415, 0.07440585], 3 [0.69169312, 0.30830688], 4 …, 5 [0.99088494, 0.00911506], 6 [0.81732224, 0.18267776], 7 [0.35925132, 0.64074868]]) 8 LogisticRegression Training Accuracy: 0.87 9 LogisticRegression Validation Accuracy: 0.81 10 LogisticRegression Testing Accuracy: 0.81   The output of logistic regression is usually a probability, which means the probability our observation is positive, or y = 1. For our case, it’s the probability that the customer will churn. It is also possible to look at factors or possible features responsible for this churn in our dataset. We can do that by carrying out a feature importance. Now that we’ve trained our model, we will save it on our machine with pycaret.classification.save_model, for which we can use inside Tableau by passing the link to the location of the file. Step4: Working with Tableau Here, we ensure TabPy is connected with Tableau Desktop. We confirm that by opening http://localhost:9004/ After then, you open a calculated field and put in the code below. Drag this field in the Pane and see your predictions values. 1 SCRIPT_REAL(“import pandas as pd 2 import pycaret.classification 3 the_model=pycaret.classification.load_model (‘C:/Users/Cndro/Downloads/churn_model’) 4 X_pred = pd.DataFrame({‘gender’:_arg1, 5 ‘SeniorCitizen’:_arg2, ‘Partner’:_arg3, 6 ‘Dependents’:_arg4,’tenure’:_arg5, 7 ‘PhoneService’:_arg6, 8 ‘MultipleLines’:_arg7,’InternetService’:_arg8, 9 ‘OnlineSecurity’:_arg9,’OnlineBackup’:_arg10, 10 ‘DeviceProtection’:_arg11, 11 ‘TechSupport’:_arg12,’StreamingTV’:_arg13, 12 ‘StreamingMovies’:_arg14,’Contract’:_arg15, 13 ‘PaperlessBilling’:_arg16,’PaymentMethod’:_arg17, 14 ‘MonthlyCharges’:_arg18,’TotalCharges’:_arg19}) 15 pred = pycaret.classification.predict_model(the_model,X_pred) 16 return pred[‘Label’].tolist()”, 17 ATTR([gender]),ATTR([SeniorCitizen]),ATTR([Partner]), ATTR([Dependents]), 18 ATTR([Tenure]),ATTR([PhoneService]),ATTR([MultipleLines]), ATTR([InternetService]), 19 ATTR([OnlineSecurity]),ATTR([OnlineBackup]), ATTR([DeviceProtection]),ATTR([TechSupport]), 20 ATTR([StreamingTV]),ATTR([StreamingMovies]), ATTR([Contract]),ATTR([PaperlessBilling]), 21 ATTR([PaymentMethod]),ATTR([MonthlyCharges]), ATTR([TotalCharges])   Hope you found this article helpful.  Thanks for reading.

Blogs

How to Use Office 365 Calendar: The Ultimate Guide

                                                                       Photo by Windows on Unsplash What is Office 365 Calendar? The Microsoft Office 365 suite of business applications is packed with helpful features, and the Calendar is no exception. This digital scheduler lets you keep track of important events and appointments with ease. And because it’s a cloud-based service, you can access your calendar from virtually any computer or mobile device. If you use the Office 365 Calendar, you probably already know it’s an essential tool for managing your busy schedule. But did you know that the Calendar in Office 365 has many useful features that can help you manage your time more effectively? If not, don’t worry — this article will explain everything you need to know about using the Microsoft Office 365 Calendar app to stay organized and on track every day of the week! How to Access the Microsoft Office 365 Calendar Before you start using the Calendar in Office 365, you need to know how to access it first. There are a couple of pretty easy ways you can access Office 365 calendar. The first way is to go to this address: outlook.live.com. It will open an outlook page where you have the email, calendar, and the to-do tabs at the bottom left of the page. Click on the calendar tab, and boom…there you are! Another way to access the Calendar is by going through Bing. Go to www.bing.com on your browser and click on the three dots tab at the top. You’d see a drop down, scroll down to Office and select the Calendar option. The last and the easiest way to access the Calendar is to simply type Calendar in your browser and allow your browser to complete it. However, this works best with google calendar. Office 365 Calendar Overview The Calendar interface is shown in the image below. It’s a free version so it has limited features. However, you can perform basic functions like creating events, sharing your calendar, add calendars, edit calendars, view holidays, and others. Viewing your Calendar You can choose different views for your calendar. You can choose week, month, week, work week, and day view. How to Create an Event in Office 365 Calendar To create an event in Calendar, simply click on the menu “New Event” at the top left corner of the page. A new page pops up that allows you to create an event. Here, you have the scheduling assistant, response options, show as, and categorize. Editing Events on the Calendar To edit an event on the calendar, open the event by clicking on it. Change the details you wish to modify and save. Deleting Events on the Calendar If you wish to remove an event, you can delete it by clicking on the event(specifically, click on the event time) in the calendar. You will see the delete option, select and your event will be deleted. Another method is to click on the edit button, a new page would be opened, at the top left corner, you’ll see the delete option. Sharing your Calendar with Others You can share your Calendar with people inside or outside your organization. It’s easy to do that. Go to the share menu at the top right corner of the page, click on it to share. You can share through an email and set permissions for the user. Wrapping Up Calendar is one such program that can be used to keep track of events and appointments. It also allows users to create their own custom calendars and manage various events and reminders. Hope you enjoyed reading this article. If you do, comment and share with your friends. See you in our next post.

Blogs

Important TabPy Functions You Need To Know

                                                                       Photo by AltumCode on Unsplash In our previous tutorial, we did an introduction on what TabPy(Tableau Python Server) is and why everyone should start using it. Just as discussed, TabPy is an API which enlarges Tableau’s capabilities by allowing users to execute Python scripts and saved functions via Tableau’s table calculations. With TabPy, we can handle our data exploration and visualization better, and the ability to use Python programming language here is the main deal. Now, let’s discuss each of the python functions we can use to write our TabPy code. SCRIPT_BOOL: This function is mainly used whenever you want to return a Boolean output from a given calculation. e.g. TRUE/FALSE SCRIPT_INT : This function can be used whenever you want to return an output of type integer from the given calculation. e.g. -2,-1, 0, 2 SCRIPT_REAL: This function is also used whenever you intend to return an output of type real from the given calculation. e.g. -.25, 0, 2/3 SCRIPT_STR: This is used for returning an output of type string from the given calculation. e.g. “Jack”, “red”. Let’s move further and see how we can use each of the functions; SCRIPT_BOOL: Verify if Profit is Greater than Zero In our demonstration, we want to loop through our profit values and see if some of the values are greater than Zero or not. The output we get here should be a True or False response. From the image  above, we used our SCRIPT_BOOL function here. We opened an empty list named verify, which is to store our result. On the next line we looped through _arg1, this _arg1 stands for the Profit measure which we passed in at the last line. Looping through this _arg1, we checked if our data values is greater than zero and pass in the result by appending via the empty list and return the list. We used the calculation in our view, which is what we have below; SCRIPT_INT: Looping through Profit Value With the SCRIPT_INT function, we’ll loop through our profit value and now divide the profit by 100 and round the expected value. Let’s check below and see how it’s done. From the image above, we demonstrated by looping through the _arg1, the _arg1 here represents the profit and now we could see an empty list was declared which we named “total”. This empty list is where we passed the result of our calculation after dividing by 100 and rounding it up. The reason this empty list was used is for Tableau to handle our result efficiently and if possible to avoid errors. We used this calculation in our view, which is what we have here below; SCRIPT_REAL: Finding Relationship Between Sales and Profit With the SCRIPT_REAL function, we’ll calculate the correlation we have between the sales and Profit, which is more like knowing the relationship we have between both. Our result should be either negative or positive correlation, between the range of -1 and 1. In our calculation here, we will import a library, which is the Numpy library and we need to use 2 measures now(i.e. Sales & Profit). Just as we’ve done earlier whereby we’ve been passing our argument as _arg1. Here, the _arg1 will stand for Sales and _arg2 will stand for Profit. Let’s see the calculation below; We tested with the view we have here below; SCRIPT_STR: Extracting Customer’s Last Name In this demonstration, we’ll use our SCRIPT_STR function to extract each customer’s last name. Here, we will loop through the customer’s name and use the split function in python to split on whitespaces and with list indices, we extract the Last name. We used the code below; Let’s use this calculation in our view, we have each of the customer’s Last name extracted as seen below; Hope you enjoyed this post. Thanks for reading.

Blogs

Why You Need to Start Exploring TabPy

                                                       Photo by Fotis Fotopoulos on Unsplash TabPy is an Analytics Extension from Tableau that allows users to execute Python Scripts and saved functions using Tableau. With TabPy, we can run Python Script on the fly and display results as a visualization. It is also possible to control data sent to TabPy by interacting with the Tableau worksheet and dashboard via the parameters. We all know Python programming is the most popular language used to work on various statistical problems. Using this language with Tableau is a significant improvement in improving the effectiveness of a Developer. Now, let’s discuss why you need to start using TabPy. Key Reasons For Data Cleaning Purpose: With TabPy, we can perform data cleaning on messy data by removing non-useful columns, missing values, and as well any other actions we might want to perform. TabPy gives Developers the feel of working smarter. For Building predictive algorithms: Predictive Modeling is a way we use our data and statistics to predict the outcome of a data model. This process is also known as predictive analysis. Therefore, using TabPy, we can build our Predictive Algorithms inside Tableau. Churn prediction: Churn Prediction is another vital aspect business owners mostly dwell on. With TabPy, we can learn when and why users leave. We can also detect patterns we need in our data, predict and prevent them from happening. Writing Calculated Field in Python: We can also write our calculated field with Python without using Tableau with the help of TabPy. Using Python whenever we want to do advanced analytics is also always advisable. Lead scoring: Leads generation is another essential sector lot of business owners works hard to convert leads into payable customers. We can create an efficient conversion funnel with Python for scoring users’ behavior with a predictive model. This can be made possible with TabPy as well. Now that we’ve seen the major reasons TabPy is very good to use in Tableau, let’s see how we can install it. How to Install TabPy We’ll install TabPy using Anaconda Navigator through the Anaconda Prompt. Step 1 Open your Anaconda prompt and create a virtual environment using the below command. This isn’t compulsory, though. 1 conda create — name virtualenv Step 2 Now, let’s upgrade our pip version with the command below. 1 python -m pip install — upgrade pip Step3 Our Pip has been upgraded, and we can move further to install TabPy. From the image below, TabPy was installed earlier on my machine. 1 pip install tabpy   Step 4 By now, you should have TabPy installed on your machine. Let’s run the server now. We can run using the command below inside the same Anaconda prompt. So, you type tabpy, and you should have a similar image we have below. 1 tabpy Now, you open your browser and visit this URL http://localhost:9004/ to verify the web service is running. You should have an image like this. Step 5 What we need to do next is to make Tableau connected with Tabpy, open our Tableau Desktop, and click on help -> Settings and Performance ->Manage Analytics Extension Connection. This brings up a pop-up. You select TabPy as the External Service, indicate the server as localhost and Port as 9004, then click OK. Now we’ve created a connection. Have you started exploring TabPy ? What was your experience like? Share your thoughts in the comments section below.

Blogs

Why Power Query is Important in Power BI

                                                              Photo by Susannah Burleson on Unsplash This tutorial will discuss why Power Query is essential to Power BI. Microsoft Power BI, as we all know, is a business analytic solution that allows you to visualize your data and share insights in an organization. Several services have been made available for users to use among all the Power BI Desktop, which is free. We use this tool daily for producing interactive visuals and for all sorts of data visualization. Also, non-technical business users can use this tool for whatever they want to do, and this tool requires no upfront training. Let’s move to our topic of interest, the Power Query. The Power Query is listed among other components of Power BI, such as the Power Pivot, Power View, Power Map, and Power Q&A. Each of these components has a cogent role they play in helping users meet their business needs. Power Query The Power Query is a data transformation tool and a preparation engine that came with Microsoft Excel and Microsoft Power BI. This tool helps users process and manage data of different file types such as Excel, CSV, Web Pages, Databases, e.t.c. We can use Power Query to combine data from these various sources, derive new columns, reshape this data, format and write formulas for advanced data manipulations. We have two ways to access Power Query, and you can either use it via Power BI Desktop or Online. Since we’ve defined Power Query, let’s look at why it’s being used a lot. Key reasons for using this tool Power Query provides connectivity to a wide range of data sources, including data of different sizes and structures. This highly interactive tool gives users excellent guidance for building queries over any data source. With Power Query, we can work over a subset of a dataset to carry out data transformations and filter to our desired size. Power Query also provides consistency of experience and parity of query capabilities over all data sources. We can manually refresh Power Query or use its scheduled refresh capabilities. With Power Query, we can reshape data by transposing, grouping, pivoting, un-pivoting, e.t.c. We can also write formulas to perform advanced manipulation of data. Overview of Power Query Interface To gain access to the Power Query Editor, open your Power BI Desktop, bring in sample data, go to the Home tab, and click Transform data. After you’ve clicked on the Transform data, you should have an interface as shown below; The image shows five different tabs: Home, Transform, Add Column, View, Tools, and Help. Each of these tabs has a crucial role in assisting the analyst in manipulating data to his desired choice. We also have different tabs below it, which we can use to transform our data. We can play around with these different menus to generate the new cleaned and structured data format we want. Another key thing to note is our Data Pane at the center, the left Pane, and Query settings on the Right. The Data Pane at the center is where we have our view and see what’s going on in our data, while the Pane on the left shows us the number of ongoing queries with each query name displayed. The Right Pane is also regarded as Query Settings, which displays all steps related to each query. Did you find this post helpful? Let us know in the comments section below and follow for more educative posts.

Scroll to Top