Pandas > View data info

Name
Code
Output
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("dataframe correlation")
print (dataframe.corr())
dataframe
   C1  C2  C3
0  82  71  74
1  62  12   8
2  97  86  26
3  26  98  48
4   5  97  29
dataframe correlation
          C1        C2        C3
C1  1.000000 -0.339904  0.107885
C2 -0.339904  1.000000  0.456666
C3  0.107885  0.456666  1.000000
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("dataframe covariance")
print (dataframe.cov())
dataframe
   C1  C2  C3
0  59  45  78
1  24  43  84
2  65  68  56
3  72  21  54
4   4  14  44
dataframe covariance
        C1      C2     C3
C1  861.70  279.55   41.3
C2  279.55  459.70  152.2
C3   41.30  152.20  289.2
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
print ("describe dataframe")
print (dataframe.describe())
dataframe
   C1  C2  C3  C4
0  28  88  51  26
1   4  81  68  63
2  53  86  90  36
3  61  99  27  95
4  39  97  59  13
describe dataframe
              C1         C2         C3         C4
count   5.000000   5.000000   5.000000   5.000000
mean   37.000000  90.200000  59.000000  46.600000
std    22.394196   7.596052  23.075962  32.700153
min     4.000000  81.000000  27.000000  13.000000
25%    28.000000  86.000000  51.000000  26.000000
50%    39.000000  88.000000  59.000000  36.000000
75%    53.000000  97.000000  68.000000  63.000000
max    61.000000  99.000000  90.000000  95.000000
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(3, 2)), columns=['C1','C2'])
print ("dataframe")
print (dataframe)
print ("Info axis")
print (dataframe.keys())
dataframe
   C1  C2
0  15  99
1  40   2
2   5  79
Info axis
Index(['C1', 'C2'], dtype='object')
dataframe = pandas.DataFrame(numpy.random.randint(0,10,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("number of dataframe dimensions")
print (dataframe.ndim)
dataframe
   C1  C2  C3
0   6   5   9
1   2   7   2
2   0   4   2
3   1   9   6
4   8   8   4
number of dataframe dimensions
2
dataframe = pandas.DataFrame(numpy.random.randint(0,10,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("dataframe number of elements")
print (dataframe.size)
dataframe
   C1  C2  C3
0   2   8   2
1   9   7   2
2   9   4   3
3   5   5   7
4   0   1   0
dataframe size
15
dataframe = pandas.DataFrame(numpy.random.randint(0,10,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("dataframe info")
print (dataframe.info())
dataframe
   C1  C2  C3
0   3   5   5
1   0   8   2
2   8   1   1
3   9   5   4
4   4   7   0
dataframe info
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 3 columns):
C1    5 non-null int64
C2    5 non-null int64
C3    5 non-null int64
dtypes: int64(3)
memory usage: 200.0 bytes
None
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
shape = dataframe.shape
print ("dataframe shape")
print (shape)
print ("shape axis 0")
print (shape[0])
print ("shape axis 1")
print (shape[1])
dataframe
   C1  C2  C3  C4
0  20   7  74  62
1  40  70  16  12
2  48  34  42  98
3  66  86  41  74
4  79  33   7  56
dataframe shape
(5, 4)
shape axis 0
5
shape axis 1
4
dataframe = pandas.DataFrame({
    'C1': pandas.date_range('20170101', periods=4),
    'C2' : [10,20,30,40],
    'C3': pandas.Categorical(['A','B','C','D']),
    'C4': 1})
print ("dataframe column types")
print (dataframe.dtypes)
dataframe column types
C1    datetime64[ns]
C2             int64
C3          category
C4             int64
dtype: object
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
print ("dataframe columns")
print (dataframe.columns)
dataframe
   C1  C2  C3  C4
0  54  50  37  74
1  46  76   8  96
2  43  92  25  69
3  55  64  58   5
4  58  79   6  39
dataframe columns
Index(['C1', 'C3', 'C3', 'C4'], dtype='object')
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
print ("dataframe head")
print (dataframe.head(2))
dataframe
   C1  C2  C3  C4
0  59  94   5  79
1  67  43  21  88
2  74  68  75  79
3  62  40  75  59
4  99  76  18  84
dataframe head
   C1  C3  C3  C4
0  59  94   5  79
1  67  43  21  88
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
print ("dataframe head")
print (dataframe.tail(2))
dataframe
   C1  C2  C3  C4
0  70  85   7  80
1  15  82  58  57
2  84  55  88   9
3  60   6   6  67
4  55  74  64  10
dataframe tail
   C1  C3  C3  C4
3  60   6   6  67
4  55  74  64  10