Home > Développement > Python > Read CSV

Read CSV

import numpy as np
import pandas as pd
df1 = pd.read_csv('df1', index_col=0)
df2 = pd.read_csv('df2')
df1['A'].hist()
<matplotlib.axes._subplots.AxesSubplot at 0x7fd0965d79b0>

png

df1.describe()
A B C D
count 1000.000000 1000.000000 1000.000000 1000.000000
mean -0.017755 0.048072 -0.001723 0.002432
std 0.957223 1.004197 0.982384 1.066366
min -3.693201 -2.719020 -2.987971 -3.182746
25% -0.639101 -0.652530 -0.690831 -0.676107
50% -0.017793 0.058035 -0.012805 -0.044868
75% 0.623478 0.696946 0.706496 0.721699
max 3.412236 3.199850 3.342484 2.879793
import matplotlib.pyplot as plt
plt.style.use('ggplot') # style graphique
df1['A'].hist() # histogramme
<matplotlib.axes._subplots.AxesSubplot at 0x7fd09451d358>

png

plt.style.use('dark_background')
df1['A'].hist()
<matplotlib.axes._subplots.AxesSubplot at 0x7fd094489f98>

png

df2.plot.area(alpha=0.8)
<matplotlib.axes._subplots.AxesSubplot at 0x7fd094412320>

png

df2.plot.bar()
<matplotlib.axes._subplots.AxesSubplot at 0x7fd0943e74e0>

png

df2.plot.bar(stacked=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fd094071860>

png

df1['A'].plot.hist(bins=50)
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08ff9d630>

png

df1['A'].plot.line(x=df1.index, y="B", figsize=(12,3), lw=1)
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08fda7da0>

png

df1.plot.scatter(x='A', y='B')
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08ff35400>

png

df1.plot.scatter(x='A', y='B', c='C', cmap='coolwarm')
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08fd0cb00>

png

df1.plot.scatter(x='A', y='B', s=df1['C']*200)
/usr/local/lib/python3.6/dist-packages/matplotlib/collections.py:874: RuntimeWarning: invalid value encountered in sqrt scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08ec54860>

png

df2.plot.box()
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08eb16470>

png

df = pd.DataFrame(np.random.randn(1000, 2), columns=['a','b'])
df.plot.hexbin(x='a', y='b', gridsize=25, cmap='Oranges')
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08ea9f518>

png

df2['a'].plot.kde()
<matplotlib.axes._subplots.AxesSubplot at 0x7fd08e9f2358>

png