Data Analysis

State data within a Python Class definition

Posted on

From my procedural language days, state data was easier for me to understand than in some OOP languages. It took me a while, for instance, but I finally got the syntax correct below for creating a local state variable within a Python class here: [the solution was to create the var “self.count” with the _init_ method below… […]

Data Analysis

Combinatorics problem

Posted on

You are given a ten piece box of chocolate truffles. You know based on the label that six of the pieces have an orange cream filling and four of the pieces have a coconut filling. If you were to eat four pieces in a row, what is the probability that the first two pieces you eat have an orange […]

Data Analysis

Debugging Javascript – one useful tool

Posted on

Here’s an idea for displaying those pesky ephemeral variables that come and go like ghosts in JavaScript. Check this out. I want to know if I’m reading in a CSV file properly or not. You can use for any variable / array / object. <script> // Read in a .csv file d3.csv(“../datafile.csv”, function(someData) { debugMe(someData); }); function debugMe(whateverData) […]

Data Analysis

Python Immutable strings, integers, booleans

Posted on

In Python, STRINGS, INTS, BOOLs etc. are IMMUTABLE… meaning, for example, that you cannot convert a df column that is a string to a column that is int.  However,  you can ASSIGN the values (objects) to another variable or create a new instance of that column in another dataframe   … or use .astype(int) to perform […]