What are some ways to post python pandas dataframes to slack?
<p>How can I export a pandas dataframe to slack? </p>

<p>df.to_json() seems like a potential candidate, coupled with the slack incoming webhook, but then parsing the message to display as a nice markdown/html-ized table isn't obvious to me.</p>

<p>Long time listener, first time caller, please go easy on me...</p>

<p>There is a <code>.to_html()</code> method on DataFrames, so that might work.  But if you are just looking to cut and paste, <a href="https://pypi.python.org/pypi/tabulate" rel="nofollow">Tabulate</a> is a good choice.  From the docs:</p>

<pre><code>from tabulate import tabulate
df = pd.DataFrame([["Name","Age"],["Alice",24],["Bob",19]])
print tabulate(df, tablefmt="grid")
</code></pre>

<p>Returns</p>

<pre><code>+---+-------+-----+
| 0 | Name  | Age |
+---+-------+-----+
| 1 | Alice | 24  |
+---+-------+-----+
| 2 | Bob   | 19  |
+---+-------+-----+
</code></pre>

<p>Paste that in a code block in Slack and it should show up nicely.</p>

python pandas slack