<jupyter_start><jupyter_text>DESCRIPTIVE STATISTICS<jupyter_code>data.info()
data.columns
data.shape
# Displays summary statistics for each numerical column in the dataframe
data.describe()
#select a row
data.iloc[10]
#select a range of rows 
data.iloc[10:15]
#select a range of rows with specific columns
data.iloc[10:15, 3:6]
#select a column
data["age"]
#select a range of columns
data[["age","education"]]
#how to create your own dataframe

import pandas as pd
import numpy as np

#np.random.seed(24) 
df = pd.DataFrame({'F': np.linspace(1, 10, 10)})  #create a kinda serial number feature

#concatenating another datafram with random values to the previous one
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 5), columns=list('EDCBA'))], axis=1)

#setting the value in row1 cond colum2 to null
df.iloc[0, 2] = np.nan
df
"""Function to colour values
*Negative values are RED
*Positive values are BLACK
*Values equal to zero or null are GREEN
"""


def colorNegativeValueToRed(value):
  if value < 0:
    color = 'red'
  elif value > 0:
    color = 'black'
  else:
    color = 'green'

  return 'color: %s' % color
#calling the function to the dataframe

s = df.style.applymap(colorNegativeValueToRed, subset=['A','B','C','D','E'])
s
#calling the function on a particular feature in the dataframe

d = df.style.applymap(colorNegativeValueToRed, subset=['A'])
d
#using background colour instead
def colorNegativeValueToRed(value):
  if value < 0:
    color = 'red'
  elif value > 0:
    color = 'white'
  else:
    color = 'green'

  return 'background-color: %s' % color 
o = df.style.applymap(colorNegativeValueToRed, subset=['A','B','C','D','E'])
o<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12796208530805686, 'fraction_numerical': 0.018364928909952605, 'mean_word_length': 4.864583333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '665788', 'license': 'MIT', 'n_tokens_mistral': 609, 'n_tokens_neox': 575, 'n_words': 190, 'path': 'EDA Chapter 1 (Pandas).ipynb', 'repo_name': 'Jhoie/EDA-Practicals', 'size': '1688'}