Pandas CSV¶
-
%pd_csv¶
Magic that reads in a string and parses it as a CSV with pandas.
Example of creating a magic from IPython Interactive Computing and Visualization Cookbook by Cyrille Roussou.
The example specifically is from pages 32 to 35.
It also shows the following simpler example:
In [1]: from IPython.core.magic import (register_line_magic, register_cell_magic)
pd_csv API docs¶
-
pd_csv(cell)[source][source]¶ Read in an
io.StringIO()and parse it with pandas.- Parameters
cell (str) – User input.
- Returns
df
- Return type
pandas.DataFrame
-
load_ipython_extension(ip=None)[source][source]¶ This function is called when the extension is loaded.
It accepts an IPython
InteractiveShellinstance. We can register the magic with theIPython.core.magics.register_magic_function()method.- Parameters
ip (
InteractiveShell) –