Skip to content

Instantly share code, notes, and snippets.

@sam-be
sam-be / function_to_class.py
Created April 30, 2020 09:46
[Python Class Construction] and defining a class function after creation
class MathClass:
"""A simple example class"""
def __init__(self, integer1, integer2):
self.one = integer1
self.two = integer2
def print_nums(self):
print(f'The numbers are {self.one} and {self.two}')
@sam-be
sam-be / pd_option.py
Created April 15, 2020 12:55
[Pandas Print Options] #pandas
# Change the maximum number of rows and columns printed. (`None` means unlimited).
pd.set_option('max_rows', 2) # Default is 60 rows
pd.set_option('max_columns', 2) # Default is 20 columns
# Reset the options to defaults.
pd.reset_option('max_rows')
pd.reset_option('max_columns')
# Change the options temporarily. (Settings are restored when you exit the `with` block).
with pd.option_context('max_rows', None, 'max_columns', None):
@sam-be
sam-be / pandas.py
Last active April 15, 2020 12:56 — forked from why-not/gist:4582705
[Assorted Pandas snippets] #pandas #forked #cheatsheet
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
@sam-be
sam-be / keybase.md
Last active April 14, 2020 21:22
Keybase proof

Keybase proof

I hereby claim:

  • I am sam-be on github.
  • I am sambe (https://keybase.io/sambe) on keybase.
  • I have a public key ASCwiAnRmiGS0e9e-2BMHfSrtu7mXPQF0mNhyWnFi5t0bAo

To claim this, I am signing this object: