Stacked Bar Chart in Python - Advanced
In this advanced tutorial, we delve deeper into the art of creating stacked bar charts using Python. Building upon our previous basic tutorial, we explore more sophisticated techniques to handle complex data structures and add attributes to our visualizations. We utilize data from Our World in Data to craft a country and age demographic stacked bar chart, and then we take on a new challenge: visualizing sales data for car models by different manufacturers. We begin by installing necessary external libraries and importing data from goodcarbadcar.net into a Pandas dataframe. The tutorial guides you through the process of creating a ranking of year-to-date sales by brand and setting up the […]
Creating Stacked Bar Charts in Python: A Beginner’s Guide
Data visualization is an essential aspect of data science, allowing us to understand complex data sets at a glance. One of the most effective visual tools is the stacked bar chart, which can display multiple data series stacked on top of one another. In this article, we’ll explore how to create stacked bar charts in Python using a practical example. Preparing the Environment Before diving into the data, we need to set up our Python environment. This involves installing external libraries such as requests, pandas, matplotlib, and seaborn. These can be installed using either conda or pip, depending on your preference. Getting Started with the Data Our journey begins with the acquisition of data. For this tutorial, […]
[Year 2024] How to Install AutoDock Vina on Linux
AutoDock Vina is an open-source program used for molecular docking and works on Linux, Mac, and Windows. It is designed to be user-friendly, requiring only the molecular structures of the ligand and protein, along with the binding site specification. Recently I had trouble installing AutoDock Vina on a Linux machine. The latest files in GitHub made no response to commands like ./vina_1.2.5_linux_x86_64 --version, after I changed their permissions. Also, the instruction "AutoDock Vina installation in a Conda environment" in the official document led to a failure as follows. After a struggle, I figured out a solution. Environment How to Install Vina Hit the commands below. That's it. Be sure to […]
[Year 2024] How to Install AutoDock Vina on ARM Mac
AutoDock Vina is an open-source program used for molecular docking and works on Linux, Mac, and Windows. It is designed to be user-friendly, requiring only the molecular structures of the ligand and protein, along with the binding site specification. Recently I had trouble installing AutoDock Vina v1.2.5 in a Conda environment on my M1 Mac. The instruction "AutoDock Vina installation in a Conda environment" in the official document led to a failure. After a struggle, I figured out a solution. Environment Right Commands That's it. Be sure to use conda only. No pip. Python version has to be between 3.5 and 3.8 if you are going to use Meeko, too.
How to Align Items on Two Lists Despite Spelling Variations Using Python
Sometimes you may encounter two backup folders where most files appear identical. But, to your annoyance, some are missing in one folder or the other, and some are named slightly differently, and to create a complete backup folder, you don't know which ones to keep and which ones to throw away. The following Python code uses Levenshtein distance to align the items on two lists. First, you need to install a library for Levenshtein, as well as Pandas, by opening a terminal and entering "pip install python-Levenshtein" or "pip install levenshtein." Lists 1 and 2 show recent box-office movies, but they are not identical and have spelling variations. Let's align […]
Can't Create Bootable USB Sonoma 14.1 Installer
How to clean-install macOS Sonoma is explained here. However, there is an issue with the Sonoma 14.1 installer, and it gives an error message when asked to create a bootable USB stick. So, it seems that you need to download Sonoma 14.0 first, create a bootable USB stick from it, do a clean install, and update the OS to the latest version.
Data-Driven Science and Engineering. Chapter 3 Exercises
I used Python and worked on exercises in Chapter 3 of Data-Driven Science and Engineering, 2nd Edition (2022).
Data-Driven Science and Engineering. Chapter 2 Exercises
I used Python and worked on exercises in Chapter 2 of Data-Driven Science and Engineering, 2nd Edition (2022). I started off with an easier equation, the heat equation, by modernizing the book authors' Python code. The obsolete spicy.integrate.odeint function for ordinary differential equations is now replaced with solve_ivp in the same library. For the KdV equation, the following part of the code is replaced. \(u u_x\) is transformed by using \(\widehat{u u_x} = \int_{-\infty}^{\infty}uu_x e^{-i\kappa x} dx = \int_{-\infty}^{\infty}\frac{1}{2}\frac{d(u^2)}{dx} e^{-i\kappa x} dx = \frac{1}{2}i\kappa\widehat{u^2}\). Hide · Rush Hide · Rushnoisy Hide · Rush Cleaned
Data-Driven Science and Engineering. Chapter 1 Exercises
I used Python and worked on exercises in Chapter 1 of Data-Driven Science and Engineering (2022).
How to Successfully install PyCaret on M1 Mac
Conda-forge provides an older version of PyCaret than PIP (2.3.10 vs. 3.0.2 as of June 1, 2023). You can install the latest version of PyCaret on M1 Mac by entering the following commands.
The Fall of the Metaverse: What Could Be Next?
When Facebook made a major shift in its focus and rebranded itself as Meta in 2021, many technology enthusiasts were excited at the prospect of virtual reality revolutionizing communication. Alas, it was short-lived as Meta seemingly gave up on the idea by 2023, leaving people pondering the reasons for its failure and whether the metaverse was ever achievable. Meta reportedly cancels all its Metaverse plans Update: Meta states that it "has not stopped its plans towards the Metaverse vision." Gamereactor UK There are several factors that can be attributed to Meta's downfall, including: Despite its disappointment, technological advancements may eventually make more immersive and interactive forms of remote […]
Solution to Garbled Double-Byte Fonts in Mac Matplotlib-Generated PDFs
Double-byte fonts like Japanese and Chines ones are garbled in Mac matplotlib-generated PDFs when viewed in Adobe Acrobat. This article provides a solution.
You Need to Replace Miniforge Version of Miniconda to Get Latest one
My Mac's Miniconda was old (version 4.11.0). There seemed to be a much newer version 22.11.1 available, but when I typed 'conda update -n base conda' in the terminal as instructed, the update didn't take effect (see the output below). It also looked like various issues had accumulated. Upon recollection, I installed Miniconda with Miniforge when the official Conda version for Apple Silicon was still unavailable. Conda is an open-source package management and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them. It is commonly used for data science, scientific computing, and machine learning. Miniconda is a minimal distribution of Conda. […]
Transform Your Raspberry Pi into a Print Server for Laser Printers: A Step-by-Step Guide
Recently, some Macs in my office turned unable to select double-sided/single-sided printing or set the paper size to other than US letter on a Canon's laser printer. Other Macs were OK, although they shared the OS version, software applications, and so on. Printing from Windows was not a problem, either. After troubleshooting, I could not resolve the issue by re-installing the driver and the OS to these Macs or updating the printer firmware. So, I decided to get around the problem by using Raspberry Pi as a print server, which ended up successfully. I share the steps below. Requirements Steps By following these steps, you will have a fully functional […]
How to set up Jupyter on Visual Studio Code - A comprehensive guide with sample projects
Learn how to set up Jupyter on Visual Studio Code with this comprehensive guide. Discover the benefits of using Jupyter in Visual Studio Code, and follow step-by-step instructions to get started. Try sample projects to familiarize yourself with the tools and optimize your data science and development workflow.
The Top 10 Reasons Why Non-Programmers Should Learn Python
Python is a powerful, versatile programming language widely used in many fields, from web development to data analysis, machine learning, and scientific computing. It is known for its simple, easy-to-learn syntax, making it a great choice for beginners who want to learn to program. In recent years, Python has become one of the most popular programming languages in the world and is in high demand for various job markets and industries. One of the main benefits of learning Python for non-programmers is its ease of use. Its syntax is similar to natural language, making it easy for beginners to understand and learn programming basics. Additionally, Python has clear and readable […]
Creating a Winning CV: A Step-by-Step Guide with the Help of ChatGPT
Creating a compelling curriculum vitae (CV) is essential for anyone looking to advance their career. Your CV is often the first point of contact between you and a potential employer, so it's important to make sure it's as polished and professional as possible. But with so many different elements to consider, it can be difficult to know where to start. That's why we've put together this step-by-step guide to help you create an appealing CV that will stand out from the crowd. And with the help of ChatGPT, a large language model trained by OpenAI, you can generate a CV that is tailored to your specific needs and highlight your […]
Collaborating on Jupyter Lab: How to Improve Your Data Science Workflow as a Team
Jupyter Lab is a powerful open-source web-based platform for interactive computing and data science. It allows users to create and share documents that contain live code, equations, visualizations, and narrative text. The platform has become increasingly popular among data scientists and researchers, and it's easy to see why. In this article, we will explore how Jupyter Lab can be used for collaboration and teamwork and how it can help organizations to improve their data science workflow. Collaboration features in Jupyter Lab Collaboration is a crucial aspect of data science and research. Jupyter Lab provides several features that make it easy for teams to work together. The platform allows multiple users […]
3 Risks You Need to Know Before Investing in Cryptocurrency
If you're thinking about investing in cryptocurrency, it's important to understand that there are risks involved. Cryptocurrency is a relatively new and complex market, and it can be difficult to predict what will happen to the value of different types of crypto. In this article, we'll take a look at some of the risks that you should be aware of before you decide to invest. Risks you need to know One risk to consider is the possibility of fraud or scams. Just like with any type of investment, there are people who might try to take advantage of others by selling fake crypto or promising big returns that they can't […]
Cryptocurrency Trends in 2023
Introduction Cryptocurrency is a type of digital money that uses special codes to secure financial transactions. It's called "crypto" because it uses cryptography to secure the codes. You might have heard of the most popular type of cryptocurrency, called Bitcoin. But did you know that there are actually thousands of different types of cryptocurrency being used all over the world? In the past few years, the value of cryptocurrency has gone up and down a lot. When more people start using it and investing in it, the value tends to go up. But when fewer people are interested in it, the value goes down. This can make it a little […]
Double-byte Fonts Garbled in Mac matplotlib-Generated PDFs
In Mac matplotlib-generated PDFs, double-byte characters are unreadable in Adobe Acrobat Reader while they look fine in Preview.app.
FM-7 Emulator on Mac
I installed on my Mac an emulator of Fujitsu FM-7 Series, Japanese popular PCs in the 1980's. Here are the steps. Environment Installation Installation of cmake Installation of the emulator Starting up the emulator CUI Type "python <path>/77AVEMU/scripts/runav.py" on your terminal. GUI Type "python <path>/77AVEMU/scripts/runGUI.py" on your terminal as in Step 7.
Steps to install EMBL-EBI EMBOSS on Apple Silicon Mac
EMBL-EBI EMBOSS is a set of bioinformatics tools, such as the pairwise sequence alignment software Needle, that run on Mac, Linux, and Windows. But neither Anaconda or Homebrew provides the package for Apple Silicon (ARM64). Furthermore, Safari doesn't allow users to access EMBOSS' or any other FTP site due to security concerns. Also, the command line ftp is long gone from Mac OS. The remaining option for M1 and M2 Mac users is Finder. Get it, not a web browser, to open the URL ftp://emboss.open-bio.org/pub/EMBOSS/ and download the latest source package (version 6.6.0 as of November 4, 2022). Once you have downloaded and uncompressed the tar.gz file, open Terminal.app and […]
Base64, PyScript, and WordPress
In a recent post, I found that WordPress misinterpreted indents and returned errors when I tried to run PyScript codes on it. It might be because WordPress detoxes the codes to turning them unfunctional for security reasons. So, I converted them into base64 to evade WordPress' watch. Code with no indent First, a code with no indent. I converted the above code into base64 and pasted into the py-script tag as src. The first two lines urge the browser to import the PyScript program. Results ↑No problem with hello world. Code with indents Next, a code with indents. Its result is what I am interested in. The above code was […]
Invisible Columns for TablePress Search
TablePress is a WordPress plugin to create beautiful functional tables. Its search box is particularly useful. When entities have synonyms, such as gene names like P2X1, with which P2RX1 and P2X purinoceptor 1 are synonymous, one may want to make a table searchable by synonyms while hiding them to keep the table simple. Here is a list of the Brasilian singer Astrud Gilberto's masterpieces, as an example. Titles in Portuguese and English are shown side by side. How to create a searchable invisible column You can define visibility in CSS as below. Let's hide the 2nd column. You can still search the table by English titles, although you don't see […]
Brief Review of PyScript on WordPress
Anaconda has introduced PyScript at PyCon US 2022. It enables client-side execution of Python codes in web browsers, and they say it is already compatible with Numpy, Pandas, and other third-party modules. I gave it a quick try on WordPress. Environment WordPress 5.9.3 Lightning 14.20.3 Safari 15.4 or Google Chrome 101.0.4951.54 MacOS 12.3.1 Apple M1 Pro Examples The custom HTML block seems to be the best place for PyScript codes. Some simplest codes work there. Results print("Hello, world!") Here comes the greeting! However, PysScript looks to override the default CSS settings, and the bold headings on this page are no longer bold. Similarly, bullet points of a list are missing. Whether […]
Screenplay for 1931 German Movie "Der Kongreß tanzt"
"Der Kongreß tanzt" (The Congress Dances) is a pre-World War II German musical film, in which the Russian Tzar meets and falls in love with a common girl when the Congress of Vienna is stuck. It became such a box-office hit in Japan that Studio Ghibli's anime "The Wind Rises (風立ちぬ)" depicted diners in Tokyo in the 1930's singing its theme song "Das gibt's Nur Einmal" all together. As a student in that era, my father loved the movie for life. Recently, I came across the screenplay in his library and scanned it in PDF. The pages are even-numbered; odd pages are for the Japanese translation. If my understanding is […]
Simplest Way to Block Spam Comments
My WordPress posts would be swamped with dozens of spam comments, all from Russia. With just a few clicks, I have successfully blocked them to regain my peace of mind. It is extremely simple if your website is proxied by Cloudflare. Log in to your Cloudflare account, go to Security > Firewall Rules, set up a rule like below, and block access from the country(-ies) altogether. Unless your website is about Russian liberal arts or the like, you will lose practically nothing by doing so.
Notes on the Book "Effective Pandas"
The book I introduced in the last post has turned out to be so fantastic that I have decided to make notes of it. This is a live document; I started from Chapter 21 and am going on from there. I will return to the earlier chapters if I still have time and power. The author recently appeared in Real Python Podcast: Becoming More Effective at Manipulating Data with Pandas and talked about the book. Introduction Installation Data Structures Seris Introduction Series Deep Dive Operators (& Dunder Methods) Aggregate Methods Conversion Methods Manipulation Methods Indexing Operations String Manipulation Date and Time Manipulation Plotting with a Series Dates in the Index […]
Book: Effective Pandas
Harrison, M. (2021) Effective Pandas: Patterns for Data Manipulation. Independently published. Pandas is a Python library for data analysis and visualization, and I use it almost every day. Python Podcast's interview with the Pandas guru Matt Harrison led me to buy his book "Effective Pandas." It walks you through the library and demonstrates the way to use it effectively in data analyses. I'm just halfway through but am much impressed at the tips and the philosophy beneath, and in particular, at the simple but revolutionary "chaining" syntax, in which you write a method per line, chained one after another (see the example code below.) It makes code development much easier […]
Pandas: Reproduction of Microarray Study Results
This is a step-by-step guide to reproduce the results of a microarray study by using Pandas, scikit-learn, and other Python scientific libraries. Here, my target is the principal component analysis (PCA) conducted in Lukk M, Kapushesky M, Nikkilä J, et al. A global map of human gene expression. Nat Biotechnol. 2010;28:322-324. doi:10.1038/nbt0410-322. Data retrieval The authors provide all their datasets at the repository 'E-MTAB-62 - Human gene expression atlas of 5372 samples representing 369 different cell and tissue types, disease states and cell lines.' Let's look and see what's there. Four files are listed in addition to lots of raw data. Namely, E-MTAB-62.idf.txt Investigation description E-MTAB-62.sdrf.txt Sample and data relationship […]
How to Get Japan's Treasury Interest Rates Retrieved in Pandas
Steps The Ministry of Finance provides the historical data of Japan's Treasury interest rates here. https://www.mof.go.jp/english/policy/jgbs/reference/interest_rate/historical/jgbcme_all.csv You can import and convert the data directly into a dataframe using Pandas' read_csv function. Since there are three digits below the decimal point and interest rates seem unlikely to have exceeded 100% in the last half-century in Japan, five significant figures will be sufficient, and thus I can safely set the dtype as np.float16. 1Y 2Y 3Y 4Y ... Date 1974-09-24 10.327 9.362 8.830 8.515 ... 1974-09-25 10.333 9.364 8.831 8.516 ... 1974-09-26 10.340 9.366 8.832 8.516 ... 1974-09-27 10.347 9.367 8.833 8.517 ... Here is the code for the chart above.
Variables exported from Mac's Photos.app to XMP
There is an option to "Export IPTXC as XMP" when you export photos from Mac's Photos.app by selecting File>Export>Export Unmodified Original... Variables in XMP is useful for arranging photos. but what are they? I have tinkered with variables on Photos and by using exiftool to map them onto those in XMP files. Here is the correspondence table. Information edited on Photos is prioritized over EXIF metadata. XMP Photos.app EXIF dc:title Title Title photoshop:DateCreated Date and time Date/Time Original exif:GPSTimeStamp - Date/Time Original dc:description Caption Image Description rdf:li Keyword, People ? exif:GPSLongitudeexif:GPSLongitudeRefexif:GPSLatitudeexif:GPSLatitudeRef Location GPS information