python & pandas - Split large dataframe into multiple dataframes and plot diagrams
<p>I'm under the similar condition with <a href="http://stackoverflow.com/questions/19790790/splitting-dataframe-into-multiple-dataframes">this case</a>. I'm working on a project which has a large dataframe with about half-million of rows. And about 2000 of users are involving in this.( I get this number by <code>value_counts()</code> counting a column called <code>NoUsager</code>).</p>

<p>I'd like to split the dataframe into several array/dataframe for plotting after. (Several means an array/dataframe for each user)
I gott the list of users like:</p>

<pre><code>df.sort_values(by='NoUsager',inplace=True)
df.set_index(keys=['NoUsager'],drop=False,inplace=True)
users = df['NoUsager'].unique().tolist()
</code></pre>

<p>I know what's after is a loop to generate the smaller dataframes but I have no idea how to make it happen. And I combined the code above and tried the one in <a href="http://stackoverflow.com/questions/19790790/splitting-dataframe-into-multiple-dataframes">the case</a> but there was no solution for it.</p>

<p>What should I do with it?</p>

<hr>

<p><strong>EDIT</strong></p>

<p>I want both histogram and boxplot of the dataframe. With the answer provided, I already have a boxplot of all <code>NoUsager</code>. But with large amount of data, the boxplot is too small to read. So I'd like to split the dataframe by <code>NoUsager</code> and plot them separately.
Diagrams that I'd like to have:</p>

<ol>
<li>boxplot, column=<code>DureeService</code>, by=<code>NoUsager</code> </li>
<li>boxplot, column=<code>DureeService</code>, by='Weekday`</li>
<li>histogram, for every <code>Weekday</code>,by=<code>DureeService</code></li>
</ol>

<p>I hope this time is well explained.</p>

<p>DataType:</p>

<pre><code>          Weekday NoUsager Periods  Sens  DureeService
DataType   string  string  string string datetime.time
</code></pre>

<p>Sample of DataFrame:</p>

<pre><code>Weekday NoUsager Periods Sens DureeService
Lun 000001 Matin + 00:00:05 
Lun 000001 Matin + 00:00:04 
Mer 000001 Matin + 00:00:07 
Dim 000001 Soir  - 00:00:02 
Lun 000001 Matin + 00:00:07 
Jeu 000001 Soir  - 00:00:04 
Lun 000001 Matin + 00:00:07 
Lun 000001 Soir  - 00:00:04 
Dim 000001 Matin + 00:00:05 
Lun 000001 Matin + 00:00:03 
Mer 000001 Matin + 00:00:04 
Ven 000001 Soir  - 00:00:03 
Mar 000001 Matin + 00:00:03 
Lun 000001 Soir  - 00:00:04 
Lun 000001 Matin + 00:00:04 
Mer 000002 Soir  - 00:00:04 
Jeu 000003 Matin + 00:00:50 
Mer 000003 Soir  - 00:06:51 
Mer 000003 Soir  - 00:00:08 
Mer 000003 Soir  - 00:00:10 
Jeu 000003 Matin + 00:12:35 
Lun 000004 Matin + 00:00:05 
Dim 000004 Matin + 00:00:05 
Lun 000004 Matin + 00:00:05 
Lun 000004 Matin + 00:00:05 
</code></pre>

<hr>

<p>And what bothers me is that none of these data is number, so each time they have to be converted.</p>

<p>Thanks in advance!</p>

<p><code>[g for _, g in df.groupby('NoUsager')]</code> gives you a list of data frames where each dataframe contains one unique <code>NoUsager</code>. But I think what you need is something like:</p>

<pre><code>for k, g in df.groupby('NoUsager'):
    g.plot(kind = ..., x = ..., y = ...) etc..
</code></pre>

python pandas matplotlib dataframe split