Version:0.9 StartHTML:0000000105 EndHTML:0000395227 StartFragment:0000000141 EndFragment:0000395191
Program Statistical_Data_AnalysisScience_representation_pas_py_ETL;     //solution Tutor 138 finished
 //http://www.rosettacode.org/wiki/Prime_decomposition#Pascal ☮ ✞ π 📌 🐞 📊  

//https://rosettacode.org/wiki/Spiral_matrix#Delphi
//https://rosettacode.org/wiki/Zeckendorf_number_representation#Delphi
//https://rosettacode.org/wiki/Zeckendorf_number_representation#Pascal
//https://rosettacode.org/wiki/Air_mass#Delphi   🐱‍🚀 📊 📊 📊   📈 📈 📊
//https://medium.com/art-of-data-engineering/building-your-first-etl-pipeline-with-python-and-sql-3f4084a08ff1
//https://medium.com/@sarowar.saurav10/20-advanced-statistical-approaches-every-data-scientist-should-know-ccc70ae4df28
//https://blog.stackademic.com/data-analysis-with-python-pandas-and-matplotlib-advanced-a9615a3dff6f

//{$I owmapikey2.inc}
procedure Project_Functions_Weather_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     // 9. Check the Weather Without Leaving Your Terminal 
    // {$I owmapikey.inc}  //Const OWMKEY='' 
     
     
{To get the current weather data of any city using the OpenWeatherMap 
     API in Python, you can use the requests and json modules. Here is an example: 
     The OpenWeatherMap API is a service that provides weather data, including current weather data, forecasts, 
     and historical data. It offers an API with JSON, XML, and HTML endpoints, and a limited free usage tier. 
     To use the API, you need to create an account on openweathermap.org and obtain an API key.}
     execstr('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     execstr
('import requests');  
     execstr
('city = "'+loc+'"'+LF+  
     
//'api_key = "your_openweather_api_key" ');
      // 'api_key = "'+OWMKEY+'" '+LF+ 
       //'api_key = "___06543f5f70442cc5b3efe6674d2b4"'+LF+
       'data= requests.get(f''https://api.openweathermap.org/data/2.5/weather?q={city}&units=metric&appid={api_key}'').json()'+LF+ 
       
'print(f"Weather in {city}: {data[''weather''][0][''description'']}")'+LF+
       'print(f"Temperature (in celcius) = {data[''main''][''temp'']}")');  
       
    
//10. Split a PDF Into Pages   
    (*from PyPDF2 import PdfReader, PdfWriter  
      reader = PdfReader('document.pdf')  
      for i, page in enumerate(reader.pages):  
          writer = PdfWriter()  
          writer.add_page(page)  
          with open(f'page_{i+1}.pdf', 'wb') as f:  
              writer.write(f)    *)
                       
      println
(stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end; 

function TRestClient3_AskWeather(askcity: string; 
                                  aResponseHeader
:TRestResponseHandler):string;
 var jo: TJSON; rest: TRestResource;
begin
  with TRestClient.create(self) do begin
     // rest:= Resource('https://api.openweathermap.org/data/2.5/weather?q='+
     //                          askcity+'&units=metric&appid='+OWMKEY);
      println('@addr:'+objtostr(rest))
      rest.ContentType('application/json');
      ConnectionType:= hctWinInet;
      //OnResponse:= @TRestOnResponseEvent2;
    try
      jo:= TJSON.Create(); 
      jo
.parse(rest.get()); 
      result
:= jo.values['weather'].asarray[0].asobject['description'].asstring+' temp: '+
               jo.values['main'].asobject['temp'].asstring+'° at '+askcity;
      //writeln(formatjson(jo.stringify));
    finally
      Free;
      jo.Free;
    except  
      writeln
('OWM_EWI_Exc:'+ExceptiontoString(exceptiontype,exceptionparam));
    end; 
  
end; //with   
end; 
function TRestClient4_AskWeather(loc: string; 
                                  aResponseHeader
:TRestResponseHandler):string;
begin
  with TRestClient.create(self) do begin
    ConnectionType:= hctWinInet;
    //OnResponse:= @TRestOnResponseEvent2;
    try
      with TJSON.Create() do begin 
        
//parse(Resource('https://api.openweathermap.org/data/2.5/weather?q='+
        //                      loc+'&units=metric&appid='+OWMKEY).get()); 
        result:= values['weather'].asarray[0].asobject['description'].asstring+' temp: '+
                 values['main'].asobject['temp'].asstring+'° at '+loc;
        //writeln(formatjson(stringify));
        free;
      end;
    finally
      Free;
    except  
      writeln
('OWM_Except:'+ExceptiontoString(exceptiontype,exceptionparam));
    end; 
  
end; //with   
end; 
function TRestClient5_AskWeather(loc: string):string;
begin
  with TRestClient.create(self) do begin
    ConnectionType:= hctWinInet;
    //OnResponse:= @TRestOnResponseEvent2;
    try
      with TMcJsonItem.Create() do begin 
       
//7/ asJson:=(Resource('https://api.openweathermap.org/data/2.5/weather?q='+
       //                       loc+'&units=metric&appid='+OWMKEY).get()); 
        result:= values['weather'].items[0]['description'].asstring+' temp: '+
                 values['main']['temp'].asstring+'° at '+loc;
        //writeln(formatjson(tostring1));
        free;
      end;
    finally
      Free;
    except  
      writeln
('OWM_Except:'+ExceptiontoString(exceptiontype,exceptionparam));
    end; 
  
end; //with   
end; 
//type TTMatrix = array of array of double;
type TTMatrix = TMatrix;
procedure DisplayMatrix(Memo: TMemo; Mat: TTMatrix);
{Display specified matrix}
var X,Y: integer;
var S: string;
begin
S:='';
for Y:=0 to High(Mat[0]) do begin
   S:=S+'[';
   for X:=0 to High(Mat) do
     S:=S+Format('%4.0f',[Mat[X][Y]]);
   S:=S+']'+#$0D#$0A;
   end;
  Memo.Lines.Add(S);
end;
procedure DoRect5(R: TRect; var Inx: integer; var Mat: TTMatrix);
   {Create on turn of the spiral base on the rectangle}
   var X,Y: integer;
   begin
   {Do top part of rectangle}
   for X:=R.Left to R.Right do begin
      Mat[X][R.Top]:=Inx;
      Inc(Inx);
      end;
   {Do Right part of rectangle}
   for Y:=R.Top+1 to R.Bottom do begin
      Mat[R.Right][Y]:=Inx;
      Inc(Inx);
      end;
   {Do bottom part of rectangle}
   for X:= R.Right-1 downto R.Left do begin
      Mat[X][R.Bottom]:=Inx;
      Inc(Inx);
      end;
   {Do left part of rectangle}
   for Y:=R.Bottom-1 downto R.Top+1 do begin
      Mat[R.Left][Y]:=Inx;
      Inc(Inx);
      end;
   end;
Procedure SetArrayLength2Matrix(var arr: TTMatrix;
                                            asize1, asize2: Integer);
var i: Integer;
begin setlength(arr, asize1);
   for i:= 0 to asize1-1 do SetLength(arr[i], asize2);
end;   
procedure InflateRect2(var R: TRect; const DX, DY: Integer);
begin
  Dec2(R.Left, DX);
  Inc2(R.Right, DX);
  Dec2(R.Top, DY);
  Inc2(R.Bottom, DY);
end;
   
procedure MakeSpiralMatrix(var Mat: TTMatrix; SizeX,SizeY: integer);
{Create a spiral matrix of specified size}
var Inx: integer; var R: TRect;
begin
   {Set matrix size}
   //SetLength(Mat,SizeX,SizeY);
   SetArrayLength2Matrix(Mat,SizeX,SizeY);
   {create matching rectangle}
   R:=Rect(0,0,SizeX-1,SizeY-1);
   Inx:=0;
   {draw and deflate rectangle until spiral is done}
   while (R.Left<=R.Right) and (R.Top<=R.Bottom) do begin
      DoRect5(R,Inx, Mat);
      //writ('1: '+itoa(r.left)+' '+itoa(r.right)+'  '+itoa(r.top));
      inflateRect2(R,-1, -1);
      //writ('2: '+itoa(r.left)+' '+itoa(r.right)+'  '+itoa(r.top)+' '+itoa(r.bottom));
   end;      //c}
    
 
{ R:= Rect(2, 4, 7, 8);
  InflateRect2(R, 1, 2);
  WriteLn(itoa(R.Left)+' '+itoa(R.Top)+' '+itoa(R.Right)+' '+itoa(R.Bottom)); }
  
    New values of coordinates:
    Left = 2-1 ; Top = 4-2; Right = 7+1; Bottom = 8+2.
  }
end;
procedure SpiralMatrix5(Memo: TMemo);
{Display spiral matrix}
var Mat: TTMatrix;
begin
   Memo.Lines.Add('5x5 Matrix');
   MakeSpiralMatrix(Mat,5,5);
   DisplayMatrix(Memo,Mat);
   Memo.Lines.Add('8x8 Matrix');
   MakeSpiralMatrix(Mat,8,8);
   DisplayMatrix(Memo,Mat);
   Memo.Lines.Add('14x8 Matrix');
   MakeSpiralMatrix(Mat,14,8);
   DisplayMatrix(Memo,Mat);   //}
end;
var FibNums: array {[0..21]} of integer; { =
      (1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
       144, 233, 377, 610, 987, 1597, 2584,
       4181, 6765, 10946, 17711, 28657); }
       
procedure setfibnumbs;
begin
  setlength(fibnums, 21);
  fibnums:= [1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
             144, 233, 377, 610, 987, 1597, 2584,
             4181, 6765, 10946, 17711, 28657];  
end;  
function GetZeckNumber(N: integer): string;
{Returns Zeckendorf number for N as string}
var I: integer;
begin
Result:='';
{Subtract Fibonacci numbers from N}
for I:=High(FibNums) downto 0 do
 if (N-FibNums[I])>=0 then begin
   Result:=Result+'1';
   N:=N-FibNums[I];
   end
 else if Length(Result)>0 then Result:=Result+'0';
if Result='' then Result:='0';
end;  
procedure ShowZeckendorfNumbers(Memo: TMemo);
var I: integer;
var S: string;
begin
S:='';
for I:=0 to 20 do begin
   Memo.Lines.Add(IntToStr(I)+': '+GetZeckNumber(I));
   end;
end;   
// Return Zeckendorf representation of the passed-in cardinal. Pascal
function ZeckRep( C : cardinal) : string;
var
  a, b, rem : cardinal;
  j, nrDigits: integer;
begin
  // Case C = 0 has to be treated specially
  if (= 0) then begin
    result := '0';
    exit;
  end;
  // Find largest Fibonacci number not exceeding C
  a := 1;
  b := 1;
  nrDigits := 1;
  rem := C - 1;
  while (rem >= b) do begin
    //dec2( rem, b);
    rem:= rem-b;
    //inc2( a, b);
    a:= a+b;
    b := a - b;
    inc( nrDigits);
  end;
  // Fill in digits by reversing Fibonacci back to start
  SetLength( result, nrDigits);
  j := 1;
  result[j] := '1';
  for j := 2 to nrDigits do begin
    if (rem >= b) then begin
      //dec( rem, b);
      rem:= rem-b
      result
[j] := '1';
    end
    else result[j] := '0';
    b := a - b;
    //dec( a, b);
    a:= a-b;
  end;
//  Assert((a = 1) and (b = 1)); // optional check
end;
const DEF_ZECK=
   'n = 20                                         '+LF+ 
   
'def z(n):                                      '+LF+ 
   
'  if n == 0 : return [0]                       '+LF+ 
   
'  fib = [2,1]                                  '+LF+ 
   
'  while fib[0] < n: fib[0:0] = [sum(fib[:2])]  '+LF+ 
   
'  dig = []                                     '+LF+
   '  for f in fib:                                '+LF+
   '    if f <= n:                                 '+LF+
   '        dig, n = dig + [1], n - f              '+LF+
   '    else:                                      '+LF+
   '        dig += [0]                             '+LF+
   '  return dig if dig[0] else dig[1:]            ';
procedure Zeckendorf_Numbers_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     // 9. Check the Weather Without Leaving Your Terminal 
    // {$I owmapikey.inc}  //Const OWMKEY='' 
     execstr('import io, sys  # Added');
     {To get the current weather data of any city using the OpenWeatherMap 
     API in Python, you can use the requests and json modules. Here is an example: 
     The OpenWeatherMap API is a service that provides weather data, including current weather data, forecasts, 
     and historical data. It offers an API with JSON, XML, and HTML endpoints, and a limited free usage tier. 
     To use the API, you need to create an account on openweathermap.org and obtain an API key.}
     execstr('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     
     execstr
(DEF_ZECK);  
     execstr
('for i in range(n + 1):'+
             '  print(''%3i: %8s'' % (i,''''.join(str(d) for d in z(i))))');
     println(stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end;
const DeFZIGZAG =                                               
   
'def zigzag(n):                                              '+LF+
   '    ''zigzag rows''                                         '+LF+
   '    def compare(xy):                                        '+LF+
   '        x, y = xy                                           '+LF+
   '        return (x + y, -y if (x + y) % 2 else y)            '+LF+
   '    xs = range(n)                                           '+LF+
   '    return {index: n for n, index in enumerate(sorted(      '+LF+
   '        ((x, y) for x in xs for y in xs),                   '+LF+
   '        key=compare                                         '+LF+
   '    ))}                                                     '+LF+
                                                                 
   
'def printzz(myarray):                                       '+LF+ 
   
'    ''show zigzag rows as lines''                           '+LF+ 
   
'    n = int(len(myarray) ** 0.5 + 0.5)                      '+LF+ 
   
'    xs = range(n)                                           '+LF+ 
   
'    print(''\n''.join(                                      '+LF+ 
   
'       [''''.join("%3i" % myarray[(x,y)]for x in xs)for y in xs]'+LF+ 
   
'    ))                                                       ';
procedure ZigZag_Numbers_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     // 9. Check the Weather Without Leaving Your Terminal 
    // {$I owmapikey.inc}  //Const OWMKEY='' 
     execstr('import io, sys  # Added');
     {To get the current weather data of any city using the OpenWeatherMap 
     API in Python, you can use the requests and json modules. Here is an example: 
     The OpenWeatherMap API is a service that provides weather data, including current weather data, forecasts, 
     and historical data. It offers an API with JSON, XML, and HTML endpoints, and a limited free usage tier. 
     To use the API, you need to create an account on openweathermap.org and obtain an API key.}
     execstr('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     execstr
(DeFZIGZAG);  
     
//execstr('for i in range(n + 1):'+
       //      '  print(''%3i: %8s'' % (i,''''.join(str(d) for d in z(i))))');
     Execstr('printzz(zigzag(6))');  
     println
('  '+stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end;
   procedure Toggle(var I, dir: integer);
   {Toggle Direction and increment I}
   begin
   Dir:=-Dir;
   Inc(I);
   end;

   procedure Step(var X,Y, dir: integer);
   {Take one step "Dir" direction}
   begin
   X:=X+Dir;
   Y:=Y-Dir;
   end;
const Size = 10;
Procedure SetArrayLength4Matrix(var arr: TTMatrix;
                                            asize1, asize2: Integer);
var i: Integer;
begin setlength(arr, asize1);
   for i:= 0 to asize1-1 do SetLength(arr[i], asize2);
end;   

procedure ZigzagMatrix(Memo: TMemo);
var Mat: TMatrix;
var X,Y,Inx,Dir: integer;
begin
SetarrayLength4Matrix(Mat,Size,Size);
Inx:=0; X:=0; Y:=0; Dir:=1;
repeat
   begin
      Mat[X][Y]:=Inx;
      if (X+Dir)>=Size then Toggle(Y, dir)
      else if (Y-Dir)>=Size then Toggle(X, dir)
      else if (X+Dir)<0 then Toggle(Y, dir)
      else if (Y-Dir)<0 then Toggle(X, dir)
      else Step(X,Y, dir);
      Inc(Inx);
   end
until
 Inx>=Size*Size;
DisplayMatrix(Memo,Mat);
end;
const psize = 5;
procedure PascalProgramzigzag();
var
  zzarray: array [1..psize] of array[1..psize] of integer;
  element, i, j: integer;
  direction: integer;
  width, n: integer;
 
begin
  i := 1;
  j := 1;
  direction := 1;
  for element := 0 to (psize*psize) - 1 do begin
    zzarray[i][j] := element;
    i := i + direction;
    j := j - direction;
    if (= 0) then begin
        direction := -direction;
        i := 1;
        if (> psize) then begin
          j := psize;
          i := 2;
        end;
      end
    else if (> psize) then begin
        direction := -direction;
        i := psize;
        j := j + 2;
      end
    else if (= 0) then begin
        direction := -direction;
        j := 1;
        if (> psize) then begin
          j := 2;
          i := psize;
        end;
      end
    else if (> psize) then begin
        direction := -direction;
        j := psize;
        i := i + 2;
      end;
  end;
  width := 2;
  n     := psize;
  while (> 0) do begin
    width := width + 1;
    n     := n div 10;
  end;
  for j := 1 to psize do begin
    for i := 1 to psize do
      write(itoa(zzarray[i][j])+#9);
    writeln('');
  end;
end;
const RE  = 6371000; { radius of earth in meters}
const DD  = 0.001;   { integrate in this fraction of the distance already covered}
const FIN = 1e7;     { integrate only to a height of 10000km, effectively infinity}
function rho(a: double): double;
{ The density of air as a function of height above sea level.}
begin
  Result:=Exp(-/ 8500);
end;
function Radians(degrees: double): double;
{ Converts degrees to radians}
begin
  Result:= degrees * Pi / 180
end;
function Height(A, Z, D: double): double;
{ a = altitude of observer}
{ z = zenith angle (in degrees)}
{ d = distance along line of sight}
var AAA,HH: double;
begin
   AAA := RE + A;
   HH := Sqrt(AAA*AAA + D*- 2*D*AAA*Cos(Radians(180-z)));
   Result:= HH - RE;
end;
function ColumnDensity(A, Z: double): double;
{ Integrates density along the line of sight.}
var Sum,D,Delta: double;
begin
Sum := 0.0;
:= 0.0;
processmessagesOFF;
while D < FIN do begin
   delta := Maxfloat(DD, DD*D); { adaptive step size to avoid it taking forever}
   Sum:=Sum + Rho(Height(A, Z, D+0.5*Delta)) * Delta;
   D:=+ delta;
   end;
processmessagesON;   
Result
:= Sum;
end;

function AirMass(A, Z: double): double;
begin
  Result:= ColumnDensity(A, Z) / ColumnDensity(a, 0);
end;
procedure ShowAirMass(Memo: TMemo);
var Z: integer;
begin
Memo.Lines.Add('Angle     0 m              13700 m');
Memo.Lines.Add('------------------------------------');
Z:=0;
 while Z<=90 do begin
   Memo.Lines.Add(Format('%2d      %11.8f      %11.8f', [z, airmass(0, Z), airmass(13700, Z)]));
   Z:=Z+5;
  end;
end;
const DeFAIRMASS =   
   
'""" Rosetta Code task: Air_mass """                                         '+LF+
   '                                                                              '+LF+
   'from math import sqrt, cos, exp                                               '+LF+
                                                                                  
   
'DEG = 0.017453292519943295769236907684886127134  # degrees to radians         '+LF+
   'RE = 6371000                                     # Earth radius in meters     '+LF+
   'dd = 0.001      # integrate in this fraction of the distance already covered  '+LF+
   'FIN = 10000000  # integrate only to a height of 10000km, effectively infinity '+LF+
   '                                                                              '+LF+
   'def rho(a):                                                                   '+LF+
   '    """ the density of air as a function of height above sea level """        '+LF+     
   
'    return exp(-a / 8500.0)                                                   '+LF+
                                                                                  
   
'def height(a, z, d):                                                          '+LF+
   '    """                                                                       '+LF+
   '    a = altitude of observer                                                  '+LF+
   '    z = zenith angle (in degrees)                                             '+LF+
   '    d = distance along line of sight                                          '+LF+
   '    """                                                                       '+LF+
   '    return sqrt((RE + a)**2 + d**2-2*d*(RE + a)*cos((180-z)*DEG))-RE          '+LF+
   '                                                                              '+LF+
   'def column_density(a, z):                                                     '+LF+
   '    """ integrates density along the line of sight """                        '+LF+
   '    dsum, d = 0.0, 0.0                                                        '+LF+
   '    while d < FIN:                                                            '+LF+
   '        delta = max(dd, (dd)*d)  #adaptive stepsize to avoid taking forever:  '+LF+
   '        dsum += rho(height(a, z, d + 0.5 * delta)) * delta                    '+LF+
   '        d += delta                                                            '+LF+
   '    return dsum                                                               '+LF+
   '                                                                              '+LF+
   'def airmass(a, z):                                                            '+LF+
   '    return column_density(a, z) / column_density(a, 0)                        ';
    
procedure AirMass_Numbers_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     execstr('import io, sys  # Added');
     execstr('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     execstr
(DeFAIRMASS);  
     
//execstr('for i in range(n + 1):'+
       //      '  print(''%3i: %8s'' % (i,''''.join(str(d) for d in z(i))))');
     //Execstr('printzz(zigzag(6))');  
     Execstr('print(''Angle           0 m          13700 m\n'', ''-'' * 36)');
     Execstr('for z in range(0, 91, 5):  '+LF+
             '  print(f"{z:3d}      {airmass(0,z): 12.7f}    {airmass(13700,z):12.7f}")');
             
     println
('  '+stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end;
procedure ETL_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     execstr('import io, sys  # Added');
     execstr('import pandas as pd');  
     execstr
('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     
//pip install pandas sqlalchemy psycopg2
     execstr('from sqlalchemy import create_engine');  
     execstr
(DeFAIRMASS);  
     
//execstr('text_data = open(''1372_retail_sales_dataset.csv'', ''r'',encoding="utf8").read()');
     //# Load the dataset
     execstr('data = pd.read_csv(''1372_retail_sales_dataset.csv'')');
     execstr('print(data.info())'); 
     execstr
('print(data.head())'); 
     
     
//Step 2: Clean and Transform the Data
     //# Drop rows with missing values
      execstr('data_cleaned = data.dropna()');
      //# Convert sale_date to datetime
      //execstr('data_cleaned[''sale_date''] = pd.to_datetime(data_cleaned[''sale_date''])');
      execstr('data_cleaned[''Date''] = pd.to_datetime(data_cleaned[''Date''])');
      execstr('print(data_cleaned.head())');
      
      
//from sqlalchemy import create_engine
      //# Create connection to the PostgreSQL database
      //engine = create_engine('postgresql+psycopg2://user:password@localhost:5432/mydatabase')
      //# Load data into SQL
      //execstr('data_cleaned.to_sql(''sales_data'', engine, index=False, if_exists=''replace'') ');
           
     
     
//execstr('for i in range(n + 1):'+
       //      '  print(''%3i: %8s'' % (i,''''.join(str(d) for d in z(i))))');
     //Execstr('printzz(zigzag(6))');  
     //Execstr('print(''Angle           0 m          13700 m\n'', ''-'' * 36)');
     //Execstr('for z in range(0, 91, 5):  '+LF+
     //        '  print(f"{z:3d}      {airmass(0,z): 12.7f}    {airmass(13700,z):12.7f}")');
             
     println
('  '+stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end;
procedure StatDataScience_PySolution(loc: string);
begin
 with TPythonEngine.Create(Nil) do begin
   //pythonhome:= PYHOME64;
   loaddll;
   autofinalize:= false;
   try
     execstr('output = io.StringIO()') 
     execstr
('sys.stdout = output');  
     
//pip install pandas sqlalchemy psycopg2
     //execstr('from sqlalchemy import create_engine');  
     //execstr(DeFAIRMASS);  
     execstr('import pymc as pm; import numpy as np');  
     
//execstr('text_data = open(''1372_retail_sales_dataset.csv'',''r'',encoding="utf8").read()');
     //# Load the dataset
     execstr('data = pd.read_csv(''1372_retail_sales_dataset.csv'')');
     execstr('print(data.info())'); 
     execstr
('print(data.head())'); 
     
     
//Step 2: Clean and Transform the Data
     //# Drop rows with missing values
     execstr('data_cleaned = data.dropna()');
      //# Convert sale_date to datetime
      //execstr('data_cleaned[''sale_date''] = pd.to_datetime(data_cleaned[''sale_date''])');
     execstr('data_cleaned[''Date''] = pd.to_datetime(data_cleaned[''Date''])');
     execstr('print(data_cleaned.head())');
      
      
//# Suppose we observed 20 coin flips with 12 heads and 8 tails
     execstr('observ_heads = 12; observ_tails = 8');
      
     execstr
('with pm.Model() as model:  '+                       
          
'  # Prior for the bias of the coin (theta)                '+LF+
          '  theta = pm.Beta(''theta'', alpha=1, beta=1)             '+LF+
          '  # Likelihood                                            '+LF+
          '  y= pm.Binomial(''y'',n=observ_heads+observ_tails,p=theta,observed=observ_heads)'+
          '  # Posterior sampling                                    '+LF+
          '  trace = pm.sample(200, tune=1000, cores=1, chains=2)   ');
          
     execstr
('pm.summary(trace)');   
      
     execstr
('from scipy.stats import norm');
      
     
//# Generate synthetic data
     execstr('data = np.random.normal(loc=5, scale=2, size=1000)');
     //# Estimate MLE for mean and standard deviation
     execstr('mu_hat, std_hat = norm.fit(data)')
     execstr('print(f"Estimated Mean (mu): {mu_hat:.2f}")');
     execstr('print(f"Estimated Std (sigma): {std_hat:.2f}")');
      
     
//3. Hypothesis Testing (t-test)
     execstr('from scipy.stats import ttest_ind')
     //# Synthetic data
     execstr('group_A= np.random.normal(5,1,50); group_B= np.random.normal(5.5,1.2,50)');
     execstr('stat, pvalue = ttest_ind(group_A, group_B)');
      
     execstr
('print(f"T-statistic: {stat:.2f}, p-value: {pvalue:.4f}")'+LF+
      'if pvalue < 0.05:                                                     '+LF+
      '    print("Reject the null hypothesis (Significant difference).")     '+LF+
      'else:                                                                 '+LF+
      '    print("Fail to reject null hypothesis (No significant difference).")');
      
     execstr
('from sklearn.decomposition import PCA');
      //!pip install statsmodels
            
     
//6. Factor Analysis
     //!pip install factor_analyzer
     execstr('from factor_analyzer import FactorAnalyzer');
     //# Synthetic data (100 samples, 6 variables)
     execstr('X = np.random.rand(100, 6)                              '+LF+ 
             
'fa = FactorAnalyzer(n_factors=2, rotation=''varimax'')  '+LF+ 
             
'fa.fit(X)                                               '+LF+ 
             
'print("Loadings:\n", fa.loadings_)                       '); 
               
     
//7. Cluster Analysis (K-means) 
     execstr('from sklearn.cluster import KMeans ');
     //# Synthetic data: 200 samples, 2D
     execstr('X = np.random.rand(200, 2)');
     execstr('kmeans = KMeans(n_clusters=3, random_state=42)');
     execstr('kmeans.fit(X)');
     execstr('print("Cluster centers:", kmeans.cluster_centers_)');
     execstr('print("Cluster labels:", kmeans.labels_[:10])');
      
     
//9. Time Series Analysis (ARIMA)
     execstr('from statsmodels.tsa.arima.model import ARIMA ');
     //# Synthetic time series data
     execstr('np.random.seed(42);  data = np.random.normal(100, 5, 50)');
     execstr('time_series = pd.Series(data)');
     //# Fit ARIMA model (p=1, d=1, q=1)
     execstr('model = ARIMA(time_series, order=(1,1,1))');
     execstr('model_fit = model.fit()');
     //# Forecast next 5 points
     execstr('forecast = model_fit.forecast(steps=5)');
     execstr('print("Forecast:", forecast.values)');
      
     
//13. Logistic Regression
     execstr('from sklearn.linear_model import LogisticRegression');
     execstr('from sklearn.linear_model import LinearRegression');
     execstr('from sklearn.metrics import mean_squared_error');
     execstr('from sklearn.model_selection import train_test_split');
     execstr('np.random.seed(50)                                                '+LF+
             'X = np.random.rand(100, 5)                                        '+LF+
             'y = np.random.randint(0, 2, 100)  # Binary labels                 '+LF+
             'X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2) '+LF+
             'model = LogisticRegression()                                      '+LF+
             'model.fit(X_train, y_train)                                       '+LF+
             //# Predicting the target values for the test set
             //'y_pred = model.predict(X_test)                                   '+LF+
             '# Calculating the model score (R^2 score)                         '+LF+
             'accuracy = model.score(X_test, y_test)                            '+LF+
             'print(y_test)                                                     '+LF+
             'print(f"R^2 Score: {accuracy}")                                   '+LF+
             'print("Class Accuracy:", accuracy)                                ');
  
     execstr
('y_pred = model.predict(X_test)  '+LF+       
            
//# Calculating the Mean Squared Error
             'mse = mean_squared_error(y_test, y_pred)' +LF+
             'print(f"Mean Squared Error: {mse}") '+LF+
             'print(y_test)'+LF+
             'print(y_pred)  ');  
     
     
//https://www.geeksforgeeks.org/difference-between-score-and-accuracy_score-methods-in-scikit-learn/
     execstr('from sklearn.metrics import accuracy_score');       
     execstr
('# Method 3: Using accuracy_score function                 '+LF+
             'accuracy = accuracy_score(y_test, y_pred)                 '+LF+
             'print(f"accuracy_score function - Accuracy: {accuracy}")  ');        
     
     
//16. Monte Carlo Simulation     
     execstr('np.random.seed(42)                                     '+LF+
            'n_samples = 10_000_00                                   '+LF+
            'xs = np.random.rand(n_samples)                          '+LF+
            'ys = np.random.rand(n_samples)                          '+LF+
            '# Points within the unit circle                         '+LF+
            'inside_circle = (xs**2 + ys**2) <= 1.0                  '+LF+
            'pi_estimate = inside_circle.sum() * 4 / n_samples       ');  
     execstr
('print("Estimated π:", pi_estimate)');
     //17. Markov Chain Monte Carlo (MCMC)   
     
     
//# Synthetic data
    (* execstr('np.random.seed(42)'+LF+
          'data = np.random.normal(0, 1, 100)                                     '+LF+ 
          'with pm.Model() as model:                                              '+LF+ 
          '   mu = pm.Normal(''mu'', mu=0, sigma=10)                              '+LF+ 
          '   sig = pm.HalfNormal(''sigma'', sigma=1)                             '+LF+ 
          '                                                                       '+LF+ 
          '   likelihood= pm.Normal(''likelihood'',mu=mu,sigma=sig,observed=data)'+LF+ 
          '   trace = pm.sample(1000, tune=500, chains=2)                         '+LF+
          'pm.summary(trace)                                                      ');
     //*)
     
     
//execstr('from pygam import LinearGAM, s'); 
                                                                                
      
//# Create connection to the PostgreSQL database
      //engine = create_engine('postgresql+psycopg2://user:password@localhost:5432/mydatabase')
      //# Load data into SQL
      //execstr('data_cleaned.to_sql(''sales_data'', engine, index=False, if_exists=''replace'') ');
     
     
//https://blog.stackademic.com/data-analysis-with-python-pandas-and-matplotlib-advanced-a9615a3dff6f
     //import pandas as pd
      //# Creating a Series at runtime!
     execstr('data = [10,20,30,40]; series= pd.Series(data); print(series)');
    //DataFrames 
     execstr('data={''Name'':[''John'',''Jane'',''Mike''],''Age'':[23,25,30]}');
     execstr('df = pd.DataFrame(data); print(df)'); 
     
     
//# Create Employee Dataset
     execstr('data = { '+LF+
          '"Employee_ID": range(1001, 1011), '+LF+
          '"Name":["Alice","Bob","Charlie","David","Emma","Max","Grace","Helen","Isaac","Julia"],'+LF+
          '"Age":[25, 28, 35, 40, 22, 30, 45, 50, 29, 38], '+LF+
          '"Department":["HR","IT","IT","Finance","HR","Finance","IT","Marketing","HR","Finance"],'+LF+
          '"Salary":[50000,70000,85000,92000,48000,78000,110000,65000,52000,88000],'+LF+
          '"Experience_Years":[2, 4, 10, 15, 1, 8, 20, 12, 3, 11],'+LF+
          '"Performance_Score":[3.2,4.5,4.8,3.7,2.9,4.2,4.9,3.8,3.5,4.1]'+LF+
          '} ');
      //# Convert to DataFrame
     execstr('df = pd.DataFrame(data)');
      //# Display first few rows
      execstr('print(df.head())');
      
      
//Data Cleaning    # Check for missing values
      execstr('print(df.isnull().sum());  # Check data types print(df.dtypes)');
      //# Convert categorical columns to category type
      execstr('df[''Department''] = df[''Department''].astype(''category'')');
      //# Add an Experience Level column
     execstr('df[''Experience_Level''] = pd.cut(df[''Experience_Years''],'+LF+
               'bins=[0,5,10,20], labels=[''Junior'',''Mid'',''Senior''])');
      //# Show the updated DataFrame
     execstr('print(df.head())'); 
     
     
//Find Employees with High Salaries
     execstr('high_salary_df = df[df[''Salary''] > 80000]');
     execstr('print(high_salary_df)');
     //Find Average Salary by Department
     execstr('print(df.groupby(''Department'')[''Salary''].mean())');
     //Find the Highest Performing Department
     execstr('print(f"Highest Performing Department: {df.groupby("Department")["Performance_Score"].mean().idxmax()}")');     
     
     
//Step 4: Data Visualization
     //📊 1. Bar Chart — Average Salary by Department
     execstr('import matplotlib.pyplot as plt');
     execstr('import seaborn as sns');
     execstr('plt.figure(figsize=(8,5))'+LF+
      'sns.barplot(x=df[''Department''],y=df[''Salary''],estimator=np.mean,palette="coolwarm")'+LF+
      'plt.title(''Average Salary by Department'', fontsize=14)                               '+LF+
      'plt.xlabel(''Department'', fontsize=12)                                                '+LF+
      'plt.ylabel(''Average Salary'', fontsize=12)                                            '+LF+
      'plt.xticks(rotation=45)                                                                '+LF+
      'plt.show()                                                                             '); 
      
    
//📈 2. Scatter Plot — Salary vs Experience   
    execstr('plt.figure(figsize=(9,5))'+LF+
      'sns.scatterplot(x=df["Experience_Years"],y=df["Salary"],hue=df["Department"],palette="Dark2",s=100)'+LF+
      'plt.title(''Salary vs Experience'', fontsize=14)                               '+LF+
      'plt.xlabel(''Years of Experience'', fontsize=12)                               '+LF+
      'plt.ylabel(''Salary'', fontsize=12)                                            '+LF+
      'plt.legend(title="Department",bbox_to_anchor=(1, 1),fontsize=8)               '+LF+
      'plt.show()                                                                 '); 
      
    
//📊 3. Histogram — Salary Distribution
    execstr('plt.figure(figsize=(8,5))                                            '+LF+
      'plt.hist(df["Salary"], bins=5, color="blue", alpha=0.7, edgecolor="black")  '+LF+ 
      
'plt.title("Salary Distribution", fontsize=14)                               '+LF+ 
      
'plt.xlabel("Salary", fontsize=12)                                           '+LF+ 
      
'plt.ylabel("Frequency", fontsize=12)                                        '+LF+ 
      
'plt.show()                                                                  ');   
      
    
//📊 4. Box Plot — Salary by Department
    execstr('plt.figure(figsize=(8,5))                                    '+LF+
      'sns.boxplot(x=df["Department"], y=df["Salary"], palette="pastel")  '+LF+
      'plt.title("Salary Distribution by Department", fontsize=14)        '+LF+
      'plt.xlabel("Department", fontsize=12)                              '+LF+
      'plt.ylabel("Salary", fontsize=12)                                  '+LF+
      'plt.xticks(rotation=45)                                            '+LF+
      'plt.show()                                                         ');  
     
     println
('  '+stringreplace(evalstr('output.getvalue().strip()'),
                                     #10,#13#10,[rfReplaceAll, rfIgnoreCase])); 
   
except
      raiseError;
   finally
      UnloadDll;
      Free;
   end;
 end; 
end;
var d: array of int64;
  dc: array of TInteger;  C : cardinal;
 
begin   //@main
//https://rosettacode.org/wiki/Happy_numbers#DWScript
//https://python.plainenglish.io/lambda-functions-in-python-are-more-useful-than-you-think-d56ee089701d
//https://www.kaggle.com/code/maxkleiner/notebook10dae7045a/
//fpascal_solution(); 
  (* 
  writeln('program Count_the_coins_BigDecimal;');
  d := [1, 5, 10, 25];
  m := Length(d); n := 100;         //100
  Writeln(itoa(Count64(d, m, n)));  //242
  //print(changes(100000, [100, 50, 25, 10, 5, 1]));
  d := [1, 5, 10, 25, 50, 100];
  d:= [200, 100, 50, 20, 10, 5, 2, 1];    //eu_coins:= 10056050940818192726001
  //d := [10, 25];
  m:= Length(d);  n:= 100000;
  Writeln((Count64big(d, m, n)));   *)
  //Writeln('Python Request Weather Solutions:_____');
  //LLM_Torch_PySolution('Lucerne');
   //Seaborn_Lambda_PySolution('Visp');
   //Project_Functions_Lambda_PySolution('Brig');  
   
   SpiralMatrix5
(memo2);
   
   Writeln
('Delphi Solution:_____');
   setfibnumbs();
   ShowZeckendorfNumbers(memo2);
   
   Writeln
('Pascal Solution:_____');
   for C := 1 to 20 do
     WriteLn( {SysUtils.}Format( '%2d: %s', [C, ZeckRep(C)]));
   Writeln('Python Solution:_____');  
   Zeckendorf_Numbers_PySolution
('Bale');
   
   Writeln
('ZigZag Delphi Solution:_____');
   ZigzagMatrix(memo2);
   Writeln('ZigZag Pascal Solution:_____');
   PascalProgramzigzag();
   Writeln('ZigZag Python Solution:_____'+CR);
   ZigZag_Numbers_PySolution('St. Gall');
   
   Writeln
('Airmass Delphi Solution:_____');
   //ShowAirMass(memo2);
   
   Writeln
('Airmass Python Solution:_____'+CR);
   AirMass_Numbers_PySolution('Uster');
   
   Writeln
('ETL Python Solution:_____'+CR);
   ETL_PySolution('Bienne');
   
    Writeln
('Statistical Data Science Python Solution:_____'+CR);
   StatDataScience_PySolution('Wankdorf');
   
   
{
   Project_Functions_Weather_PySolution('Basel, CH');
   sleep(1000);
   Writeln('Pascal Restclient Weather Solutions:_____');
   //println(TRestClient4_AskWeather('Basel, CH', nil));
   println(TRestClient5_AskWeather('Basel, CH'));
   }
   //GetMorseTable(dots:Bool):Str;;  //whole table!
   //println(GetMorseTable(true));  //whole table!
   //RenderJS_factors();
  (* RenderJS_countcoins();
   countTheCoins_Pascal();
   *)
End.

ref:    https://www.zeitmaschine.tv/_zm/uploads/reis/html5/1632322578743.mp4
        https://x.com/i/status/1889295047192981796
        https://de.slideshare.net/slideshow/maxbox_starter138_top7_statistical_methods-pdf/275863941
        
        This code snippet trains a linear regression model
, predicts the target values for the 
        test 
set, and then calculates and prints the R² score and Mean Squared Error (MSE) for the model. 
        Feel free 
to adapt it to your specific dataset and model!
        
Scikit
-learns model.score(X,y) calculation works on co-efficient of determination i.e R^2 is a 
simple 
function that takes model.score= (X_test,y_test). It doesn't require y_predicted value 
to be supplied externally to calculate the score for you, rather it calculates y_predicted internally
 
and uses it in the calculations.
This is how it is done:
= ((y_test - y_predicted) ** 2).sum()
= ((y_test - y_test.mean()) ** 2).sum()
score = 1 - (u/v)
and you get the score ! Hope that helps.    

https
://www.bahnonline.ch/5472/tee-stiftung-in-den-niederlanden-gibt-ram-an-transportmuseum-ab/
https://www.gofundme.com/f/aankoop-teetrein-fase-1    
procedure InflateRect(var R: TRectF; const DX, DY: Single);
begin
//{$EXCESSPRECISION OFF}
  R.Left := R.Left - DX;
  R.Right := R.Right + DX;
  R.Top := R.Top - DY;
  R.Bottom := R.Bottom + DY;
//{$EXCESSPRECISION ON}
end;

Angle     0 m              13700 m
------------------------------------
 0       1.00000000       1.00000000
 5       1.00380963       1.00380965
10       1.01538466       1.01538475
15       1.03517744       1.03517765
20       1.06399053       1.06399093
25       1.10305937       1.10306005
30       1.15418974       1.15419083
35       1.21998076       1.21998246
40       1.30418931       1.30419190
45       1.41234169       1.41234567
50       1.55280404       1.55281025
55       1.73875921       1.73876915
60       1.99212000       1.99213665
65       2.35199740       2.35202722
70       2.89531368       2.89537287
75       3.79582352       3.79596149
80       5.53885809       5.53928113
85      10.07896219      10.08115981
90      34.32981136      34.36666557
 mX5  executed: 11/02/2025 16:10:25  Runtime: 0:2:18.922  Memload: 63% use
    
with processmessages OFF/ON
  mX5  executed: 11/02/2025 16:13:25  Runtime: 0:0:22.790  Memload: 64% use   

ZigZag Delphi Solution
:_____
[   0   1   5   6  14  15  27  28  44  45]
[
   2   4   7  13  16  26  29  43  46  63]
[
   3   8  12  17  25  30  42  47  62  64]
[
   9  11  18  24  31  41  48  61  65  78]
[
  10  19  23  32  40  49  60  66  77  79]
[
  20  22  33  39  50  59  67  76  80  89]
[
  21  34  38  51  58  68  75  81  88  90]
[
  35  37  52  57  69  74  82  87  91  96]
[
  36  53  56  70  73  83  86  92  95  97]
[
  54  55  71  72  84  85  93  94  98  99]
ZigZag Pascal Solution:_____
0   1   5   6   14   
2   4   7   13   15   
3   8   12   16   21   
9   11   17   20   22   
10   18   19   23   24   

ZigZag Python Solution
:_____

  
0  2  3  9 10 20
  1  4  8 11 19 21
  5  7 12 18 22 29
  6 13 17 23 28 30
 14 16 24 27 31 34
 15 25 26 32 33 35
 mX5  executed: 10/02/2025 22:07:56  Runtime: 0:0:2.749  Memload: 70% use
   
0: 0
1:
 1
2:
 10
3:
 100
4:
 101
5:
 1000
6:
 1001
7:
 1010
8:
 10000
9:
 10001
10:
 10010
11:
 10100
12:
 10101
13:
 100000
14:
 100001
15:
 100010
16:
 100100
17:
 100101
18:
 101000
19:
 101001
20:
 101010
 mX5  executed: 10/02/2025 17:45:07  Runtime: 0:0:2.482  Memload: 67% use
    https
://python.plainenglish.io/10-everyday-problems-python-can-solve-in-under-10-lines-of-code-efb6ffd3e860
    https://soundcloud.com/max-kleiner-481715070
    https://soundcloud.com/max-kleiner-481715070/g9-zeitraum-fm-127bpm-441hz?si=fe9fd03b58314bdb8621ebf9106b9184&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing
    https://www.youtube.com/watch?v=904JoHPWcek
    https://grandbrothers.bandcamp.com/album/late-reflections
    
    
If one coincidence can occur, then another coincidence can occur. And if one coincidence happens 
    
to occur just after another coincidence, then that is just a coincidence.
    
   InflateRect enlarges the rectangle by subtracting DX from the Left side 
and adding DX to the Right side, 
   
and subtracting DY from the Top and adding DY to the Bottom13. This keeps the rectangle's 
   center point in the same location while increasing its size4. 
    
    She never arrives at her destination
.
Stranded in rural Maine with a dead car and broken ankle, Tegan worries she's made a terrible mistake. 
Then a miracle occurs: she is rescued by a couple who offers her a room in their warm cabin until the snow clears.
But something isn't right. Tegan believed she was waiting out the storm, but as time ticks by, 
she comes to realize she is in grave danger. This safe haven isn't what she thought it was, and staying here may 
have been her most deadly mistake yet.  
And now she must do whatever it takes to save herselfand her unborn child.
A gut-wrenching story of motherhood, survival, and twisted expectations, #1 New York Times bestselling author Freida McFadden 
delivers a snowbound thriller that will chill you 
to the bone.
Python Request Weather Solutions:_____
Exception
: ConnectionError: HTTPSConnectionPool(host='api.openweathermap.org', port=443): Max retries exceeded with url:
 /data/2.5/weather?q=Basel,%20CH&units=metric&appid=55013bf3d09cfb0619989a00ed5bed09 (Caused by 
 NameResolutionError
("<urllib3.connection.HTTPSConnection object at 0x000002189C0DC830>: 
 Failed 
to resolve 'api.openweathermap.org' ([Errno 11001] getaddrinfo failed)")) at 861.1073
    
    Versand
übersicht
Vom Versandzentrum zu Ihnen 
(Schritt 2)
PBI (Pitney Bowes): UPAAG000000072744731
Tue
, Feb 18
1:17
pm
Label added to shipment, shipment now waiting to be handed to the last mile courier.
GENEVA
Tue
, Feb 18
12:56
pm
Forwarded 
to Delivery Office
CASE POSTALE
Tue
, Feb 18
12:04
pm
Under processing at operations facility
CASE POSTALE
Sat
, Feb 15
9:09
am
Departed Operations facility 
 In Transit
COLNBROOK
Sat
, Feb 15
8:54
am
Departed Operations facility 
 In Transit
COLNBROOK
Fri
, Feb 14
9:48
pm
Received at Origin Facility
LONDON
Fri
, Feb 14
9:40
pm
Received at Origin Facility
LONDON
Fri
, Feb 14
1:11
pm
Shipped from Global Shipping Center 
to Destination
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:54
pm
Container Closed
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:45
pm
Container Assignment
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:26
pm
Parcel Documentation 
and Labeling
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:26
pm
Second Dimension Event
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:26
pm
First Dimension Event
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:26
pm
Processing at Shipping Center
LICHFIELD
, STAFFORDSHIRE WS13 8UR
Fri
, Feb 14
12:26
pm
Record created.
LONDON
Mon
, Feb 10
6:17
pm
Tracking details uploaded
Mon
, Feb 10
11:17
am
Sendungsnummer angegeben
Vom Verk
äufer zum Versandzentrum (Schritt 1)
Sendungsnummer wird bereitgestellt
Tue
, Feb 11
4:43
pm
Delivered by
Tue
, Feb 11
4:34
pm
Item Received
Mon
, Feb 10
10:09
pm
Item Received
Mon
, Feb 10
12:53
pm
Sender despatching item
Mon
, Feb 10
11:17
am
Sendungsnummer angegeben
Weniger ansehen
    
 
// Adapted from http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/
    class Program
    {
        static long Count(int[] C, int m, int n)
        {
            var table = new long[n + 1];
            table[0] = 1;
            for (int i = 0; i < m; i++)
                for (int j = C[i]; j <= n; j++)
                    table[j] += table[j - C[i]];
            return table[n];
        }
        static void Main(string[] args)
        {
            var C = new int[] { 1, 5, 10, 25 }
;
            int m = C.Length;
            int n = 100;
            Console.WriteLine(Count(C, m, n));  //242
            Console.ReadLine();
        }
    }  
    
    def spiral
(n):
    dx,dy = 1,0            # Starting increments
    x
,= 0,0              # Starting location
    myarray 
= [[None]* n for j in range(n)]
    for i in xrange(n**2):
        myarray[x][y] = i
        nx
,ny = x+dx, y+dy
        
if 0<=nx<and 0<=ny<and myarray[nx][ny] == None:
            x,= nx,ny
        
else:
            dx,dy = -dy,dx
            x
,= x+dx, y+dy
    return myarray

def printspiral
(myarray):
    n = range(len(myarray))
    for y in n:
        for x in n:
            print "%2i" % myarray[x][y],
        print

printspiral
(spiral(5)) 
    

Warning
: Trying to access array offset on value of type bool in /htdocs/Spur N/minitrix/sortiment/detailseiten/Minitrix_16304.php on line 106
Deprecated: mysqli::query(): Passing null to parameter #1 ($query) of type string is deprecated in /htdocs/app/classes/Category.php on line 203
Fatal error: Uncaught ValueError: mysqli::query(): Argument #1 ($query) cannot be empty in /htdocs/app/classes/Category.php:203 Stack trace: #0 /htdocs/app/classes/Category.php(203): 
mysqli
->query() #1 /htdocs/app/classes/Category.php(191): Category->getProductData() #2 /htdocs/Spur N/minitrix/sortiment/detailseiten/Minitrix_16304.php(106): Category->loadProduct() 
#3 {main} thrown in /htdocs/app/classes/Category.php on line 203

C:\maxbox\maxbox4\maxbox4>py -3.12 -m pip install pymc
Collecting pymc
  Downloading pymc
-5.20.1-py3-none-any.whl.metadata (15 kB)
Collecting arviz>=0.13.0 (from pymc)
  Using cached arviz-0.20.0-py3-none-any.whl.metadata (8.8 kB)
Requirement already satisfied: cachetools>=4.2.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (5.5.0)
Collecting cloudpickle (from pymc)
  Downloading cloudpickle-3.1.1-py3-none-any.whl.metadata (7.1 kB)
Requirement already satisfied: numpy>=1.25.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (1.26.3)
Requirement already satisfied: pandas>=0.24.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (2.2.2)
Collecting pytensor<2.28,>=2.26.1 (from pymc)
  Downloading pytensor-2.27.1-cp312-cp312-win_amd64.whl.metadata (10 kB)
Requirement already satisfied: rich>=13.7.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (13.9.4)
Requirement already satisfied: scipy>=1.4.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (1.11.4)
Requirement already satisfied: threadpoolctl<4.0.0,>=3.1.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (3.2.0)
Requirement already satisfied: typing-extensions>=3.7.4 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pymc) (4.12.2)
Requirement already satisfied: setuptools>=60.0.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from arviz>=0.13.0->pymc) (75.8.0)
Requirement already satisfied: matplotlib>=3.5 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from arviz>=0.13.0->pymc) (3.9.0)
Requirement already satisfied: packaging in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from arviz>=0.13.0->pymc) (24.1)
Collecting xarray>=2022.6.0 (from arviz>=0.13.0->pymc)
  Downloading xarray-2025.1.2-py3-none-any.whl.metadata (11 kB)
Collecting h5netcdf>=1.0.2 (from arviz>=0.13.0->pymc)
  Downloading h5netcdf-1.5.0-py3-none-any.whl.metadata (13 kB)
Collecting xarray-einstats>=0.3 (from arviz>=0.13.0->pymc)
  Downloading xarray_einstats-0.8.0-py3-none-any.whl.metadata (5.8 kB)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas>=0.24.0->pymc) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas>=0.24.0->pymc) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas>=0.24.0->pymc) (2023.3)
Requirement already satisfied: filelock>=3.15 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pytensor<2.28,>=2.26.1->pymc) (3.15.4)
Collecting etuples (from pytensor<2.28,>=2.26.1->pymc)
  Downloading etuples-0.3.9.tar.gz (30 kB)
  Preparing metadata (setup.py) ... done
Collecting logical
-unification (from pytensor<2.28,>=2.26.1->pymc)
  Downloading logical-unification-0.4.6.tar.gz (31 kB)
  Preparing metadata (setup.py) ... done
Collecting miniKanren 
(from pytensor<2.28,>=2.26.1->pymc)
  Downloading miniKanren-1.0.3.tar.gz (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.3/41.3 kB 1.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting cons 
(from pytensor<2.28,>=2.26.1->pymc)
  Downloading cons-0.4.6.tar.gz (26 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied
: markdown-it-py>=2.2.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from rich>=13.7.1->pymc) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from rich>=13.7.1->pymc) (2.19.0)
Requirement already satisfied: h5py in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from h5netcdf>=1.0.2->arviz>=0.13.0->pymc) (3.12.1)
Requirement already satisfied: mdurl~=0.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from markdown-it-py>=2.2.0->rich>=13.7.1->pymc) (0.1.2)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (1.2.1)
Requirement already satisfied: cycler>=0.10 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (4.53.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (1.4.5)
Requirement already satisfied: pillow>=8 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (10.3.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from matplotlib>=3.5->arviz>=0.13.0->pymc) (3.1.2)
Requirement already satisfied: six>=1.5 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from python-dateutil>=2.8.2->pandas>=0.24.0->pymc) (1.16.0)
Collecting toolz (from logical-unification->pytensor<2.28,>=2.26.1->pymc)
  Downloading toolz-1.0.0-py3-none-any.whl.metadata (5.1 kB)
Collecting multipledispatch (from logical-unification->pytensor<2.28,>=2.26.1->pymc)
  Downloading multipledispatch-1.0.0-py3-none-any.whl.metadata (3.8 kB)
Downloading pymc-5.20.1-py3-none-any.whl (518 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 518.9/518.9 kB 1.9 MB/s eta 0:00:00
Downloading arviz-0.20.0-py3-none-any.whl (1.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 2.4 MB/s eta 0:00:00
Downloading pytensor-2.27.1-cp312-cp312-win_amd64.whl (1.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 3.0 MB/s eta 0:00:00
Downloading cloudpickle-3.1.1-py3-none-any.whl (20 kB)
Downloading h5netcdf-1.5.0-py3-none-any.whl (49 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.2/49.2 kB 2.4 MB/s eta 0:00:00
Downloading xarray-2025.1.2-py3-none-any.whl (1.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 3.2 MB/s eta 0:00:00
Downloading xarray_einstats-0.8.0-py3-none-any.whl (32 kB)
Downloading multipledispatch-1.0.0-py3-none-any.whl (12 kB)
Downloading toolz-1.0.0-py3-none-any.whl (56 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.4/56.4 kB 3.1 MB/s eta 0:00:00
Building wheels for collected packages: cons, logical-unification, etuples, miniKanren
  Building wheel 
for cons (setup.py) ... done
  Created wheel 
for cons: filename=cons-0.4.6-py3-none-any.whl size=9195 sha256=f7d85559fcfb7726b95f8f6b7ff2d3ca0507e6d6b4445e325214c31c9726bd19
  Stored 
in directory: c:\users\user\appdata\local\pip\cache\wheels\91\0c\f7\7ba4ffbf0db6bf272bee59789131f6ec2d26966307a3054267
  Building wheel 
for logical-unification (setup.py) ... done
  Created wheel 
for logical-unification: filename=logical_unification-0.4.6-py3-none-any.whl size=14016 sha256=a81c7da5232472eb8a7995fdc34aef8b0a9122370bdc6d695ff5bab0dfb087bb
  Stored 
in directory: c:\users\user\appdata\local\pip\cache\wheels\4b\07\cf\3fdaedafc40d7b1861c98be0df1bf3b2b3e87e03187fa95298
  Building wheel 
for etuples (setup.py) ... done
  Created wheel 
for etuples: filename=etuples-0.3.9-py3-none-any.whl size=12715 sha256=e12c9e11ff8e07f03c5c48690c22e4268550e4b3cd2658c6fd56e4e011ead9dd
  Stored 
in directory: c:\users\user\appdata\local\pip\cache\wheels\9e\ea\42\9562f37ce4e92913b74da9bcd504a749f0bf5d42d1d148ca76
  Building wheel 
for miniKanren (setup.py) ... done
  Created wheel 
for miniKanren: filename=miniKanren-1.0.3-py3-none-any.whl size=24007 sha256=9dd35bf8708feba5a4fdea38fc3b6de8256120344a9c590989a14092a3b38b72
  Stored 
in directory: c:\users\user\appdata\local\pip\cache\wheels\57\48\e3\441a42666f9a4ac9ccb6897d6046d81cf970c986be39938c6e
Successfully built cons logical
-unification etuples miniKanren
Installing collected packages
: multipledispatch, toolz, cloudpickle, logical-unification, h5netcdf, xarray, cons, xarray-einstats, etuples, miniKanren, arviz, pytensor, pymc
Successfully installed arviz
-0.20.0 cloudpickle-3.1.1 cons-0.4.6 etuples-0.3.9 h5netcdf-1.5.0 logical-unification-0.4.6 miniKanren-1.0.3 multipledispatch-1.0.0 
pymc
-5.20.1 pytensor-2.27.1 toolz-1.0.0 xarray-2025.1.2 xarray-einstats-0.8.0
[notice] A new release of pip is available: 24.0 -> 25.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip


C
:\maxbox\maxbox4\maxbox4>py -3.12 -m pip install statsmodels
Collecting statsmodels
  Downloading statsmodels
-0.14.4-cp312-cp312-win_amd64.whl.metadata (9.5 kB)
Requirement already satisfied: numpy<3,>=1.22.3 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from statsmodels) (1.26.3)
Requirement already satisfied: scipy!=1.9.2,>=1.8 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from statsmodels) (1.11.4)
Requirement already satisfied: pandas!=2.1.0,>=1.4 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from statsmodels) (2.2.2)
Collecting patsy>=0.5.6 (from statsmodels)
  Downloading patsy-1.0.1-py2.py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: packaging>=21.3 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from statsmodels) (24.1)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas!=2.1.0,>=1.4->statsmodels) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas!=2.1.0,>=1.4->statsmodels) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas!=2.1.0,>=1.4->statsmodels) (2023.3)
Requirement already satisfied: six>=1.5 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from python-dateutil>=2.8.2->pandas!=2.1.0,>=1.4->statsmodels) (1.16.0)
Downloading statsmodels-0.14.4-cp312-cp312-win_amd64.whl (9.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.8/9.8 MB 8.2 MB/s eta 0:00:00
Downloading patsy-1.0.1-py2.py3-none-any.whl (232 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 232.9/232.9 kB 7.0 MB/s eta 0:00:00
Installing collected packages: patsy, statsmodels
Successfully installed patsy
-1.0.1 statsmodels-0.14.4
[notice] A new release of pip is available: 24.0 -> 25.0.1
C:\maxbox\maxbox4\maxbox4>py -3.12 -m pip install factor_analyzer
Collecting factor_analyzer
  Downloading factor_analyzer
-0.5.1.tar.gz (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.8/42.8 kB 260.7 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements 
to build wheel ... done
  Preparing metadata 
(pyproject.toml) ... done
Requirement already satisfied
: pandas in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from factor_analyzer) (2.2.2)
Requirement already satisfied: scipy in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from factor_analyzer) (1.11.4)
Requirement already satisfied: numpy in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from factor_analyzer) (1.26.3)
Requirement already satisfied: scikit-learn in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from factor_analyzer) (1.3.2)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas->factor_analyzer) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas->factor_analyzer) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from pandas->factor_analyzer) (2023.3)
Requirement already satisfied: joblib>=1.1.1 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from scikit-learn->factor_analyzer) (1.3.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from scikit-learn->factor_analyzer) (3.2.0)
Requirement already satisfied: six>=1.5 in c:\users\user\appdata\local\programs\python\python312\lib\site-packages (from python-dateutil>=2.8.2->pandas->factor_analyzer) (1.16.0)
Building wheels for collected packages: factor_analyzer
  Building wheel 
for factor_analyzer (pyproject.toml) ... done
  Created wheel 
for factor_analyzer: filename=factor_analyzer-0.5.1-py2.py3-none-any.whl size=42682 sha256=8820991dc36abae7eb955168857eb3487443e75d2af5982ec3487f2e5a2be8e3
  Stored 
in directory: c:\users\user\appdata\local\pip\cache\wheels\a2\af\06\f4d4ed4d9d714fda437fb1583629417319603c2266e7b233cc
Successfully built factor_analyzer
Installing collected packages
: factor_analyzer
Successfully installed factor_analyzer
-0.5.1
[notice] A new release of pip is available: 24.0 -> 25.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip


C
:\maxbox\maxbox4\maxbox5>

----
app_template_loaded_code----
----
File newtemplate.txt not exists - now saved!----