Data Science and ChatGPT

Diwash sapkota
4 min readDec 14, 2022

--

Let’s see how you can use ChatGPT for Data Science projects.

Photo by Luke Chesser on Unsplash

ChatGPT is a large language model trained by OpenAI. It has been trained on a massive amount of data and can generate human-like text in response to input from a user. ChatGPT is capable of understanding and responding to a wide range of topics, including conversation, questions, and even jokes. Because of its ability to generate human-like text, ChatGPT can be used to create chatbots, virtual assistants, and other applications that require natural language processing. ChatGPT is based on the GPT-3 model, which is one of the most advanced language models in the world. The model uses a transformer architecture and deep learning techniques to generate high-quality text. ChatGPT is highly customizable, so developers can use it to create a wide range of applications. Overall, ChatGPT is a powerful tool for natural language processing and can be used to create a wide range of applications.

The usage of ChatGPT for programming and data science is presented here. Fi.rstly, you need to sign up for an account if you don’t have one.

If you’re new to ChatGPT, you must use this link to register an account.

You need to enter your email address and contact number to create an account. Once your account is created, you will see a screen that looks like the one below:

Let’s look at the things we can do with ChatGPT.

1. Ask Coding Questions

Until now, for all sorts of coding errors and problems, we used to go to Stack Overflow and hope that one of the most popular responses contains the answer. But now, you can ask the same questions to ChatGPT. Suppose we want to know how to check palindrome in Python. Now we make an inquiry.

This is just a tiny example of what ChatGPT is able to do. You can make inquiries on implementing other libraries of python as well. ChatGPT answers them in an easy and concise manner.

2. Translating Python Code to R and Vice-versa

Let’s say, you are a data scientist proficient in Python. And you are new to R. Now, if you want to translate your Python code to R, you can simply tell the ChatGPT to do it for you.

ChatGPT not only accomplishes the job, but it also explains the function and how to use it in R. This is very handy for individuals who can hardly print a “Hello World in R”

But wait, there’s more! What if you’re working with dataframes in Python and need to repeat your work in R for any reason? ChatGPT can assist you.

#Translate the following function from Python to R:
def get_stats(event_name):
df_stats = df[df['event_name']==event_name]
stats = df_stats['player_id']
stats = stats.value_counts()
return statsdf_stats = df[df[‘event_name’]==event_name]

After seeing the results, you now know that you may select columns in R using the $ sign and that the table function in R is equal to pandas’.value counts.

I even tested the code in R, and it worked well!

3. Natural Language to SQL Queries

OpenAI allows you to write SQL Queries with natural language. Let us examine this with a simple query.

4. Classifying Text

ChatGPT can also be useful in classifying the texts. Let’s see how it works

5. Visualizing Data

There are several other cool things you can do with ChatGPT. Check out this link to explore more on ChatGPT and its use-cases.

--

--