quaintitative

I write about my explorations in AI and other quaintitative areas.

For more about me and my other interests, visit playgrd, quaintitative or socials below


Categories
Subscribe

Data Analytics in Blender - Pandas and Quandl in Blender

Once I knew that I could use Python to script in Blender, an obvious question that came to mind was whether I could use it for data analytics and visualisation.

And the answer is of course, yes!

But before I begin showing how one could visualise data within the Blender environment, an important first step is how one could use key libraries needed for data analytics in Blender.

There are a number of ways this could be accomplished, but in this tutorial, I will just share my preferred way of importing the Pandas and Quandl libraries within the Blender Python environment.

The Python that runs within Blender is not the one that you usually use on your computer. It sits in a different location, and looks for installed libraries in different folders.

To see the paths that Blender’s Python checks, simply type the following in the Python console.

import sys
print(sys.path)  

You could get pip installed in one of these paths, and be able to install libraries directly within Blender’s Python. But I rather keep these clean. It’s simpler to start a new environment with virtualenv, install the libraries you want within that, and get Blender to look for libraries at in that virtualenv instance.

You need to first make sure that the version of Python on Blender is the same as that in the virtualenv instance. Check that by typing the following in the Python console.

import sys
print(sys.version)

Once you know that (it should be 3.5 on Blender 2.79), start a virtualenv with the same version of Python.

virtualenv -p python3 venv

Activate it.

source venv/bin/activate

Install what you need using pip.

pip install pandas
pip install quandl

Now, check where the location of the libraries are. Look for the one with ‘site-packages’

echo "import sys; print(sys.path)" | python 

Go into the Python console in Blender and add this path.

import sys
sys.path.append('/Users/<user-name>/<path>/<to>/venv/lib/python3.5/site-packages')

And that’s it. You can now use pandas to munge data; or quandl to fetch data from within Blender! Do note that the path you just appended is not persistent. When you restart Blender, you will need to append the path again.


Articles

Comparing Prompts for Different Large Language Models (Other than ChatGPT)
AI and UIs
Listing NFTs
Extracting and Processing Wikidata datasets
Extracting and Processing Google Trends data
Extracting and Processing Reddit datasets from PushShift
Extracting and Processing GDELT GKG datasets from BigQuery
Some notes relating to Machine Learning
Some notes relating to Python
Using CCapture.js library with p5.js and three.js
Introduction to PoseNet with three.js
Topic Modelling
Three.js Series - Manipulating vertices in three.js
Three.js Series - Music and three.js
Three.js Series - Simple primer on three.js
HTML Scraping 101
(Almost) The Simplest Server Ever
Tweening in p5.js
Logistic Regression Classification in plain ole Javascript
Introduction to Machine Learning Right Inside the Browser
Nature and Math - Particle Swarm Optimisation
Growing a network garden in D3
Data Analytics with Blender
The Nature of Code Ported to Three.js
Primer on Generative Art in Blender
How normal are you? Checking distributional assumptions.
Monte Carlo Simulation of Value at Risk in Python
Measuring Expected Shortfall in Python
Style Transfer X Generative Art
Measuring Market Risk in Python
Simple charts | crossfilter.js and dc.js
d3.js vs. p5.js for visualisation
Portfolio Optimisation with Tensorflow and D3 Dashboard
Setting Up a Data Lab Environment - Part 6
Setting Up a Data Lab Environment - Part 5
Setting Up a Data Lab Environment - Part 4
Setting Up a Data Lab Environment - Part 3
Setting Up a Data Lab Environment - Part 2
Setting Up a Data Lab Environment - Part 1
Generating a Strange Attractor in three.js
(Almost) All the Most Common Machine Learning Algorithms in Javascript
3 Days of Hand Coding Visualisations - Day 3
3 Days of Hand Coding Visualisations - Day 2
3 Days of Hand Coding Visualisations - Day 1
3 Days of Hand Coding Visualisations - Introduction