Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2020 15:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
def monkey_patch_pandas():
import pandas as pd
import functools
def _grep(self, *args, **kwargs):
if not hasattr(self, '_greppable'):
self._greppable = pd.Series(self.to_csv().split('\n')[1:-1])
i = self._greppable.str.contains(*args, **kwargs)
return self.iloc[i.values]
pd.DataFrame.grep = _grep
# from pylab import *
# %load_ext line_profiler
import pandas as pd
import numpy as np
import pandas
from importlib import reload
line_width = 1000
pd.options.display.width = line_width
pd.options.display.max_columns = 100
pd.options.display.max_rows = 1000
pd.options.display.min_rows = 40
pd.options.display.width = 1000 # never wrap
# see for where I now turn off jedi completely.
# import jedi
# jedi.settings.case_insensitive_completion = False
# crashes on MacOS from plotting. Is this still needed?
from sys import platform as sys_pf
if sys_pf == 'darwin':
print('using darwing tkagg')
import matplotlib
except Exception as e:
print('skipping startup/ due to exceptions')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment