Simple-Dataframe-For-Statsmodel

Fri 14 November 2025
from __future__ import print_function
import statsmodels.api as sm
import pandas as pd
from patsy import dmatrices
df = sm.datasets.get_rdataset("Guerry", "HistData").data
df.head()
dept Region Department Crime_pers Crime_prop Literacy …

Category: statsmodel

Read More

Simple-Dataframe-From-Statsmodels

Fri 14 November 2025

title: "Simple DataFrame From StatsModels" author: "Raja CSP Raman" date: 2019-04-22 description: "-" type: technical_note draft: false


from __future__ import print_function
import statsmodels.api as sm
import pandas as pd
from patsy import dmatrices
df = sm.datasets.get_rdataset("Guerry", "HistData").data
df.head()

Category: statsmodel

Read More

Simple-Entropy

Fri 14 November 2025

title: "Simple Entropy" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import math
from collections import Counter
import timeit
import numpy as np
def eta(data, unit='natural'):
    base = {
        'shannon' : 2.,
        'natural' : math.exp(1),
        'hartley' : 10.
    }

    if len(data) <= 1:
        return 0

    counts = Counter()

    for d in data …

Category: basics

Read More

Simple-Match

Fri 14 November 2025

title: "Simple Match" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


import re
content = "Eminem means positive"
a = re.search('^Em.*ve$', content)
if(a):
    print('matched')
else:
    print('not matched')
matched

More situations

  • Match Canadian postal code
  • Phone number
  • Start with /home
  • Contains /User/raja


Score …

Category: regex

Read More

Simple-Multiplication

Fri 14 November 2025

title: "Simple Multiplication" author: "Raja CSP Raman" date: 2019-05-09 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.random_normal([2, 2])
b = tf.random_normal([2, 2])
a
<tf.Tensor 'random_normal_3:0' shape=(2 …

Category: tensorflow-work

Read More

Simple-Numba

Fri 14 November 2025

title: "Numba Simple" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from numba import njit, prange
import numpy as np

@njit(parallel=True)
def add(A):
    s = 0
    # Without "parallel=True" in the jit-decorator
    # the prange statement is equivalent to range
    for i in prange(A.shape …

Category: numba

Read More

Simple-Plot

Fri 14 November 2025

title: "Simple Plot" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import matplotlib.pyplot as plt
import numpy as np
N = 128
x = np.linspace(-5, 5, N)
y = np.exp(-x**2)

y_fft = np.fft.fftshift(np.fft.fft(y).real)
plt.plot(x, y_fft)

plt …

Category: plot

Read More

Simple-Plot-20241203

Fri 14 November 2025

!pip show matplotlib | grep "Version:"
Version: 3.9.3
# !pip install matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [50, 40, 80, 40]
x, y
([1, 2, 3, 4], [50, 40, 80, 40])
plt.plot(x, y, 'ro')

plt.axis([0, 10, 20, 100])
(0.0 …

Category: plot

Read More

Simple-Plot-7808

Fri 14 November 2025

title: "Simple Plot" author: "Rj" date: 2020-20-29 description: "Simple Plot on Plotly" type: technical_note draft: false


import plotly.graph_objects as go

fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()
    <script type="text/javascript">
    window.PlotlyConfig = {MathJaxConfig: 'local'};
    if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web …

Category: plotly

Read More

Simple Query

Fri 14 November 2025

title: "Simple Query" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import os
import sys
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

Base = declarative_base()
class City(Base …

Category: sqlalchemy

Read More
Page 130 of 146

« Prev Next »