Check if a value exists in pandas dataframe index

I am sure there is an obvious way to do this but cant think of anything slick right now. Basically instead of raising exception I would like to get True or False to see if a value exists in pandas df index. import pandas as pd df = pd.DataFrame({‘test’:[1,2,3,4]}, index=[‘a’,’b’,’c’,’d’]) df.loc[‘g’] # (should give False) … Read more

“ImportError: No module named” when trying to run Python script

I’m trying to run a script that launches, amongst other things, a python script. I get a ImportError: No module named …, however, if I launch ipython and import the same module in the same way through the interpreter, the module is accepted. What’s going on, and how can I fix it? I’ve tried to … Read more

How to embed HTML into IPython output?

Is it possible to embed rendered HTML output into IPython output? One way is to use from IPython.core.display import HTML HTML(‘<a href=”http://example.com”>link</a>’) or (IPython multiline cell alias) %%html <a href=”http://example.com”>link</a> Which return a formatted link, but This link doesn’t open a browser with the webpage itself from the console. IPython notebooks support honest rendering, though. … Read more

How to display pandas DataFrame of floats using a format string for columns?

I would like to display a pandas dataframe with a given format using print() and the IPython display(). For example: df = pd.DataFrame([123.4567, 234.5678, 345.6789, 456.7890], index=[‘foo’,’bar’,’baz’,’quux’], columns=[‘cost’]) print df cost foo 123.4567 bar 234.5678 baz 345.6789 quux 456.7890 I would like to somehow coerce this into printing cost foo $123.46 bar $234.57 baz $345.68 … Read more