Top Tweets for #rulesofcode
Forgot to include venv in poetry project?
Do poetry env list
Then poetry env remove --all
Set
poetry config --local virtualenvs.in-project true
Run poetry install
The .venv folder will now be inside the project folder.
Note to self #RulesOfCode
I mistakenly ran
git branch newBranchName
instead of
git checkout -b newBranchName
And it worked. Is this new?
Apparently, it's in the git docs too. A new branch can be created using the "git branch" command.
https://t.co/JnxbF1e7Rs
Note to self. #RulesOfCode
If the difference between the python versions is only the last digit (e.g python 3.10.x to python 3.10.y) then you don't need to manually uninstall the previous one.
The windows installer will replace the old with the new.
Note to self #RulesOfCode
ref: https://t.co/Hj1yqnrfbc
If there is something that you have to do multiple times but in a slightly different way each time, use factory pattern.
If you do it the same way all the time => decorator pattern
Learning about design patterns.
Note to self #RulesOfCode
I bring good news.
27 emails successfully sent to 54 email addresses in less than a minute, built and assembled from a blank page this morning by this girl.
My email automation worked.
Stack: Pandas, HTML, win32, difflib
All brought together by Python.
Notes #RulesOfCode
To string-split a column into multiple df_columns, add expand=True as such
df[[new_col1, new_col2]] = df[col].str.split(", ", 1, expand=True)
Note to self #RulesOfCode
Write tests for your code.
Run tests as part of the continuous integration workflow to verify the integrity of incoming code.
Implement scheduled builds to pick up changes in dependencies that could break the tool.
Use codecov to track where you need to add tests
#RulesOfCode
Looping through a DataFrame (df)
df.iterrows() returns a tuple of (index, values_as_Series) for each row in the DataFrame.
Values need to be accessed by square indexing the tuple e.g tup[1][col1] returns col1's value for that row.
Note to self #RulesOfCode
to open a file from the vs code terminal to the same instance of vs code (i.e don't open a new vs code window with the file), run
code -r https://t.co/yevebhybgc
in the folder where the file is found.
-r means --reuse-window
Note to self #RulesOfCode
The opposite of hardcoding is softcoding.
Literally.
I didn't expect that.
Some things are actually as easy as they seem.
Note to self #RulesOfCode

int("99.99") does work
However
int("99") works
and
int(99.99) works
And I don't know why
Is it because "99.99" (string float) is two steps away from being an integer?
Note to self #RulesOfCode
Last year, I wrote a guide for people who will like to analyze data about Wikipedia edit data but it just stayed with me, more or less.
Then this week, I remembered again that it exists. Note to self #RulesOfCode
Here: https://t.co/PiqDaIGFrh

The coolest code thing I learned this week is that to merge two dictionaries do
dict3 = dict1 | dict2
For keys that exist in both dicts, the value from dict 2 will be prioritized.
Note to self #RulesOfCode
Whoa
I think I just learnt how to form the hex code for colors in css.
R G B
If I want red then only red should be full and the others should be empty so
red = #ff0000
Green = #00ff00
Like that.
I had no idea
Note to self #RulesOfCode
Do you ever see some data and wonder if it follows a pattern?
I do that sometimes but I tend to look at graphs of my variable instead.
There's a better way: ECDFs
Empirical cumulative distribution functions.
Note to self #RulesOfCode
For example,
Instead of multiplying an array by a DataFrame row by row, I came across df.multiply
Blew the array into a DataFrame of similar shape
And then multiplied
Note to self #RulesOfCode
the mean indicates the center of the data
the variance indicates the spread
deviation is gotten by subtracting the mean from each value, however averaging it tends to zero.
So we square the deviations before averaging, the result is called variance.
Note to self #RulesOfCode
None as an argument in plots is funny😄
marker = None : no markers
linestyle = None : default straight line
color = None : color will be blue because blue is the default color of matplotlib.
Note to self #RulesOfCode
interpolation is predicting the value at a point that is within range of the measured (reference) values.
extrapolation is predicting the value of a point that is out of the measured range.
Note to self #RulesOfCode
Have humans grown taller over time?
To investigate whether the variance in height between a parent generation and our generation, use bootstrap + permutation testing but scramble (permute) only one of the datasets.
Note to self #RulesOfCode
Last Seen Hashtags on Sotwe
Trends for you
Most Popular Users

Elon Musk 
@elonmusk
240.1M followers

Barack Obama 
@barackobama
119.3M followers

Donald J. Trump 
@realdonaldtrump
111.6M followers

Cristiano Ronaldo 
@cristiano
108.9M followers

Narendra Modi 
@narendramodi
107M followers

Rihanna 
@rihanna
97.3M followers

NASA 
@nasa
92.1M followers

Justin Bieber 
@justinbieber
90.6M followers

KATY PERRY 
@katyperry
86.8M followers

Taylor Swift 
@taylorswift13
80.6M followers

Lady Gaga 
@ladygaga
72.1M followers

Kim Kardashian 
@kimkardashian
69.4M followers

YouTube 
@youtube
68.6M followers

Virat Kohli 
@imvkohli
68.5M followers

Bill Gates 
@billgates
63.4M followers

The Ellen Show
@theellenshow
62.5M followers

CNN 
@cnn
61.9M followers

Neymar Jr 
@neymarjr
61M followers

X 
@x
60.9M followers

CNN Breaking News 
@cnnbrk
59.9M followers
