Bamboolib: One of the Most Useful Python Libraries You Have Ever Seen | by Ismael Araujo | Towards Data Science

I love writing about Python libraries. If you have read any of my blogs, you might know I have written about multiple libraries. Before writing, I test some Python libraries, check their most remarkable features, and, if I like, I write about them. Usually, I try to include a few libraries in the same blog to make it more informative. However, once in a while, I find libraries that are so cool that deserve their own blog. That’s the case for Bamboolib!
Bamboolib is one of those libraries that makes you think: How didn’t I know this before? Yeah, it sounds a little dramatic, but believe me, you will be surprised. Bamboolib can build the code for things that take a while to write, such as complex group by clauses. Let’s jump right in because I’m very excited to show you how it works.
Bamboolib sells itself as making any person do Data Analysis in Python without becoming a programmer or googling syntax. Based on my tests, that’s true! It requires zero coding skills. However, I see how it could be handy for people running short in time or for someone who doesn’t want to type long codes for simple tasks. I can also see how people learning Python can take advantage of it. For example, if you want to learn how to do something in Python, you can use Bamboolib, check the code it generates, and learn from it.
Either way, let’s explore how you can use it, and you can decide if it can be helpful for you or not. Let’s get started!
Installing Bamboolib is simple. I have written about different ways to install it in this blog, showing how to create an environment before installing Bamboolib. If you are not in the mood to create a new environment, you can just type pip install — upgrade bamboolib — user in your terminal, and it will work just fine. Now you can import it to a Jupyter Notebook by typing import bamboolib as bam, and we are good to go.
Now, we will need a dataset. I will use the All Video Games Sales dataset because it seems fun, but you can use anything you like. Once you have downloaded your dataset, let’s import it, and that’s when we can start using Bamboolib.
Remember that I said that Bamboolib doesn’t require coding? I’m serious about it. To import a dataset to your Jupyter Notebook, type bam, and it will show you a UI where you can import your dataset with three clicks.
Type bam > Read CSV file > Navigate to your file > Choose the file name > Open CSV file
Note that Bamboolib imported Pandas and created the code for you. And yeah, it will work like this throughout the whole project.
You loaded the data and realized that the date column is a string. Then, click on the column type (the little letter on the side of the column name), select the new datatype, the format, choose a new name if you want to, and click in execute.
Did you see that more code was added in the cell as well?
Also, it seems like the user_review column is an object. Let’s fix this by creating an integer.
Remember that I said that the little letter on the side of the column name is the column datatype? If you look at the letter on the side of user_review column name, you will see an f instead of i as in integer, even though I changed the datatype to be an integer. That’s because Bamboolib understood the datatype as float, so instead of throwing an error, it just fixed it for you.
Instead of changing the column datatype and name, what if you need a new column with a different datatype and name? Just click on the column datatype, select the new format and name, and click in execute. You will see the new column in the dataset immediately.
In the image below, I selected the meta_score column, changed the datatype to float, chose a new name, and the new column was created.
If you realize that you don’t need a column, just search for drop in the Search transformations box, select drop, choose the column you want to drop, and click in execute.
Now you need to rename a column, and it can’t be any easier. Just search for rename, choose the column you want to rename, write the new column name, and click execute. You can select as many columns as you wish.
Let’s say you need to split a column with people’s names into two columns, one with the first name and another one with the last name. You can easily do that. I’m splitting the game’s name for demonstration purposes, which doesn’t really make sense, but you can see how it works.
Just type split in the Search transformation box, choose the column you want to split, the separator, and the maximum of columns you want to have. Boom!
Since this was just a demonstration, let’s drop the additional columns. Search for drop, select the columns you want to drop, and click in execute.
And then, we can select to visualize only a few columns. Here I will select the game name, the platform, and the score. Just type select in the Search transformation, choose the columns you want to select and execute.
At the end of these steps, Bamboolib create the following code that someone could use even if they don’t have Bamboolib installed. Pretty cool, right?
If you want to filter your dataset or create a new one with filtered information, you can search for filter in the Search transformation, choose what you want to filter, decide if you want to create a new dataset, and click on execute. That simple!
If you need to merge two datasets, just search for merge, select the two datasets you want to merge, the type of join, select the key column you wish to use to merge the datasets, and click in execute. You can create a new dataset or just edit the current one.
In case you want to extract a string such as the day of the week and the month from a date column, do you know the code, or would you have to Google it? Well, with Bamboolib, you don’t need either one. Just search for extract datatime property, select the date column, and choose what you want to extract.
There are multiple options for you to play around with. I must confess that I didn’t know how to do that or if that was even possible to do using Pandas... And I just learned something new.
Using group by is one of the most valuable things that you can do with Pandas. However, it can get very complex at times. Luckily, Bamboolib can make group by very intuitive and easy. Search for the group by in the Search transformation box, choose the columns you want to group, and then select the calculations you want to see.
In this example, I want to see the count and the average score of the games for each platform. Doing this, I just learned that PlayStation 4 has the lowest score average among all the platforms.
Bamboolib is a great tool to create quick data visualizations. For example, to create histograms, click on create plot, select the figure type, the x-axis, and that’s pretty much it. You just created a nice chart with four clicks.
Or you can create a box plot. The process is very similar. Nice and easy!
There are many other types of charts to explore, but the all games dataset isn’t the best option to create graphs. You can test this feature with other datasets, though. There is a lot to explore.
Bamboolib makes data exploration super easy. You can get insights from your dataset with a click. To do so, click on Explore DataFrame, and it will return information such as summary statistics with mean, median, quartiles, standard deviation, number of observations, missing values, number of positive and negative observations, and much more. It also creates charts so that you can understand the data distribution.
If you have DateTime datatypes in the dataset, it can also create charts showing how the data changed throughout the time. So instead of wasting time creating individual charts to understand a dataset, you can use this feature to get insights about it.
Phew! I’m now satisfied for having given the attention that this library deserves. And yes, I know that this is not the first blog about Bamboolib out there, but I wanted to have my take on it. There is a lot more to explore. Bamboolib has a lot of potentials to transform the way we analyze data and how we learn. I have been using Pandas for a few years, and I learned new things that we could do using Bamboolib. Thanks for reading, and I’ll see you in the next blog.
You might also like...
5 Python Libraries That You Don’t Know About, But Should4 Cool Python Libraries That You Should Know About4 Amazing Python Libraries That You Should Try Right Now