Category : AI

On October 28, the total number of new cases of COVID19 worldwide set a record for a single day (530581/Day). More than 20 countries/regions added record new cases of COVID19. They are most European countries. Following coutries covid19 new cases hit record for a single day: #Italy #Germany #Ukraine #Belgium #Poland #Romania #Portugal #Lebanon #Azerbaijan ..

Read more

from pyspark.sql import SparkSession from pyspark.sql.types import * #data types from pyspark.sql import functions as F #functions spark=SparkSession.builder.appName(‘XIU-Daily’).getOrCreate() input_fn = ‘s-p-tsx-60-futures_01.csv’ df = spark.read.csv(input_fn,header=True,inferSchema=True) df.show(3) +——————-+—–+ | date|value| +——————-+—–+ |1999-09-07 00:00:00|416.5| |1999-09-08 00:00:00|417.2| |1999-09-09 00:00:00|421.5| +——————-+—–+ df=df.withColumn(‘Date’,F.date_format(‘date’,’yyyy-MM-dd’)) #change date format df=df.withColumn(‘current_date’,F.current_date()) #current date df=df.withColumn(‘year’,F.year(‘date’)) df=df.withColumn(‘month’,F.month(‘date’)) df=df.withColumn(‘dayofmonth’,F.dayofmonth(‘date’)) df=df.withColumn(‘minute’,F.minute(‘date’)) df=df.withColumn(‘second’,F.second(‘date’)) df=df.withColumn(‘dayofyear’,F.dayofyear(‘date’)) df=df.withColumn(‘dayofweek’,F.dayofweek(‘date’)) df=df.withColumn(‘weekofyear’,F.weekofyear(‘date’)) df=df.withColumn(‘quarter’,F.quarter(‘date’)) df=df.withColumn(‘next_day_Mon’,F.next_day(‘date’,’Mon’)) df=df.withColumn(‘next_day_Tue’,F.next_day(‘date’,’Tue’)) df=df.withColumn(‘next_day_Wed’,F.next_day(‘date’,’Wed’)) ..

Read more

import pandas as pd from datetime import datetime fn=’s-p-tsx-60-futures_01.csv’ sp=pd.read_csv(fn) sp=sp.rename(columns={‘ value’:’value’}) sp[‘date’]=pd.to_datetime(sp.date) sp[‘Year’]=pd.DatetimeIndex(sp[‘date’]).year sp[‘Month’]=pd.DatetimeIndex(sp[‘date’]).month sp[‘dayofweek’]=sp[‘date’].dt.dayofweek sp[‘dayofmonth’]=pd.DatetimeIndex(sp[‘date’]).day sp[‘dayofyear’]=pd.DatetimeIndex(sp[‘date’]).dayofyear sp.tail(5) date value Year Month dayofweek dayofmonth dayofyear 5176 2020-04-23 857.4 2020 4 3 23 114 5177 2020-04-24 868.7 2020 4 4 24 115 5178 2020-04-27 879.7 2020 4 0 27 118 5179 2020-04-28 888.5 2020 4 ..

Read more

GaussianModel Build-in model: GaussianModel(pdf) Build-in model: GaussianModel (CDF) LorentzianModel Build-in model: LorentzianModel(pdf) Build-in model: LorentzianModel (CDF) SplitLorentzianModel VoigtModel Build-in model: VoigtModel(pdf) Build-in model: VoigtModel (CDF) PseudoVoigtModel SkewedVoigtModel MoffatModel Build-in model:MoffatModel Pearson7Model Build-in model: Pearson7Model(pdf) StudentsTModel Build-in model: StudentsTModel(pdf) Build-in model: StudentsTModel (CDF) BreitWignerModel Build-in model: BreitWignerModel(pdf) LognormalModel Build-in model: LognormalModel(pdf) Build-in model: LognormalModel (CDF) DampedOcsillatorModel ..

Read more

This example is used for fitting world covid-19 cases number import numpy as np import pandas as pd from datetime import datetime from lmfit import Minimizer, Parameters, report_fit import chart_studio.plotly as py import cufflinks as cf def Cauchy_cumulative_hazard_fit(x,loc,scale,decaybase): decayterm=np.power(decaybase,(x-loc)) decayterm[np.whe..

Read more

df2[‘date’] = df1[‘date’].values df2[‘hour’] = df1[‘hour’].values It’s better use inter join case.tail(3) caseCA caseON caseDaily CAcaseDailyON case_Date_province 2020-04-26 47864 15411 1598.0 498.0 2020-04-27 49499 15868 1635.0 457.0 2020-04-28 50982 16337 1483.0 469.0 test.tail(3) testCA testON testDailyCA testDailyON date_testing 2020-04-26 734824 229638 23570.0 12020.0 2020-04-27 765056 242188 30232.0 12550.0 2020-04-28 787612 253040 22556.0 10852.0 case_test = ..

Read more

import pandas as pd from plotly.offline import iplot import cufflinks cufflinks.go_offline() # Set global theme cufflinks.set_config_file(world_readable=True, theme=’pearl’) fig=df.iplot(asFigure=True, mode=’lines+markers’, size=6, secondary_y = ‘Increase’, secondary_y_title=’Increase’, xTitle=’Date’, yTitle=’Cases’, title=’Projected COVID-19 Cases in South Korea’, theme=’solar’) fig.show() import pandas as pd import chart_studio.plotly as py from ipywidgets import interact, interact_manual import cufflinks as cf @interact def plot_ProjectedSouthKereaCOVID19(): fig=output.iplot(asFigure=True, ..

Read more

df.orderBy(‘colname1′,’colname2’,ascending=False) from pyspark.sql.functions import sort_array df = spark.createDataFrame([([2, 1, 3],),([1],),([],)], [‘data’]) df.show() +———+ | data| +———+ |[2, 1, 3]| | [1]| | []| +———+ df0=spark.createDataFrame(df.select(sort_array(df.data).alias(‘r’)).collect(),[‘data’] df0.show() +———+ | data| +———+ |[1, 2, 3]| | [1]| | []| +———+ df1=spark.createDataFrame(df.select(sort_array(df.data, asc=False).alias(‘r’)).collect(),[‘data’]) df1.show() +———+ | data| +———+ |[3, 2, 1]| | [1]| | []| +..

Read more