Houston  Sipes

Houston Sipes

1603792800

Blowing away the MS Dev Show with the awesomeness of Raygun!

Recently Raygun’s co-founder and CEO John-Daniel Trask was a guest on the awesome MS Dev Show with hosts Carl and Jason discussing a range of topics including:

  • Raygun (obviously)
  • How Google Chrome will prevent your monitors from sleeping
  • Office “Touch” for Windows
  • Cloud Platform Roadmap
  • Date and time formatting for humans
  • Raspberry Pi 2

.@Traskjd_ blows us away with the awesomeness of @Raygunio at _http://t.co/FpMPhZHTbg#devlifepic.twitter.com/PW8h0Us2qB

_— MS Dev Show (@msdevshow) _February 10, 2015

Not only is this generally a great listen for all developers, if you’re wondering how Raygun can benefit your business, save you time and improve your software quality, this episode gives a great overview of how Raygun can help you achieve that.

Listen to this episode

We think Carl and Jason are doing a great job with the show and encourage you to subscribe to the MS Dev Show for a weekly hit of developer related news and guest interviews.

#dev

What is GEEK

Buddha Community

Blowing away the MS Dev Show with the awesomeness of Raygun!
Callum Slater

Callum Slater

1653465344

PySpark Cheat Sheet: Spark DataFrames in Python

This PySpark SQL cheat sheet is your handy companion to Apache Spark DataFrames in Python and includes code samples.

You'll probably already know about Apache Spark, the fast, general and open-source engine for big data processing; It has built-in modules for streaming, SQL, machine learning and graph processing. Spark allows you to speed analytic applications up to 100 times faster compared to other technologies on the market today. Interfacing Spark with Python is easy with PySpark: this Spark Python API exposes the Spark programming model to Python. 

Now, it's time to tackle the Spark SQL module, which is meant for structured data processing, and the DataFrame API, which is not only available in Python, but also in Scala, Java, and R.

Without further ado, here's the cheat sheet:

PySpark SQL cheat sheet

This PySpark SQL cheat sheet covers the basics of working with the Apache Spark DataFrames in Python: from initializing the SparkSession to creating DataFrames, inspecting the data, handling duplicate values, querying, adding, updating or removing columns, grouping, filtering or sorting data. You'll also see that this cheat sheet also on how to run SQL Queries programmatically, how to save your data to parquet and JSON files, and how to stop your SparkSession.

Spark SGlL is Apache Spark's module for working with structured data.

Initializing SparkSession 
 

A SparkSession can be used create DataFrame, register DataFrame as tables, execute SGL over tables, cache tables, and read parquet files.

>>> from pyspark.sql import SparkSession
>>> spark a SparkSession \
     .builder\
     .appName("Python Spark SQL basic example") \
     .config("spark.some.config.option", "some-value") \
     .getOrCreate()

Creating DataFrames
 

Fromm RDDs

>>> from pyspark.sql.types import*

Infer Schema

>>> sc = spark.sparkContext
>>> lines = sc.textFile(''people.txt'')
>>> parts = lines.map(lambda l: l.split(","))
>>> people = parts.map(lambda p: Row(nameap[0],ageaint(p[l])))
>>> peopledf = spark.createDataFrame(people)

Specify Schema

>>> people = parts.map(lambda p: Row(name=p[0],
               age=int(p[1].strip())))
>>>  schemaString = "name age"
>>> fields = [StructField(field_name, StringType(), True) for field_name in schemaString.split()]
>>> schema = StructType(fields)
>>> spark.createDataFrame(people, schema).show()

 

From Spark Data Sources
JSON

>>>  df = spark.read.json("customer.json")
>>> df.show()

>>>  df2 = spark.read.load("people.json", format="json")

Parquet files

>>> df3 = spark.read.load("users.parquet")

TXT files

>>> df4 = spark.read.text("people.txt")

Filter 

#Filter entries of age, only keep those records of which the values are >24
>>> df.filter(df["age"]>24).show()

Duplicate Values 

>>> df = df.dropDuplicates()

Queries 
 

>>> from pyspark.sql import functions as F

Select

>>> df.select("firstName").show() #Show all entries in firstName column
>>> df.select("firstName","lastName") \
      .show()
>>> df.select("firstName", #Show all entries in firstName, age and type
              "age",
              explode("phoneNumber") \
              .alias("contactInfo")) \
      .select("contactInfo.type",
              "firstName",
              "age") \
      .show()
>>> df.select(df["firstName"],df["age"]+ 1) #Show all entries in firstName and age, .show() add 1 to the entries of age
>>> df.select(df['age'] > 24).show() #Show all entries where age >24

When

>>> df.select("firstName", #Show firstName and 0 or 1 depending on age >30
               F.when(df.age > 30, 1) \
              .otherwise(0)) \
      .show()
>>> df[df.firstName.isin("Jane","Boris")] #Show firstName if in the given options
.collect()

Like 

>>> df.select("firstName", #Show firstName, and lastName is TRUE if lastName is like Smith
              df.lastName.like("Smith")) \
     .show()

Startswith - Endswith 

>>> df.select("firstName", #Show firstName, and TRUE if lastName starts with Sm
              df.lastName \
                .startswith("Sm")) \
      .show()
>>> df.select(df.lastName.endswith("th"))\ #Show last names ending in th
      .show()

Substring 

>>> df.select(df.firstName.substr(1, 3) \ #Return substrings of firstName
                          .alias("name")) \
        .collect()

Between 

>>> df.select(df.age.between(22, 24)) \ #Show age: values are TRUE if between 22 and 24
          .show()

Add, Update & Remove Columns 

Adding Columns

 >>> df = df.withColumn('city',df.address.city) \
            .withColumn('postalCode',df.address.postalCode) \
            .withColumn('state',df.address.state) \
            .withColumn('streetAddress',df.address.streetAddress) \
            .withColumn('telePhoneNumber', explode(df.phoneNumber.number)) \
            .withColumn('telePhoneType', explode(df.phoneNumber.type)) 

Updating Columns

>>> df = df.withColumnRenamed('telePhoneNumber', 'phoneNumber')

Removing Columns

  >>> df = df.drop("address", "phoneNumber")
 >>> df = df.drop(df.address).drop(df.phoneNumber)
 

Missing & Replacing Values 
 

>>> df.na.fill(50).show() #Replace null values
 >>> df.na.drop().show() #Return new df omitting rows with null values
 >>> df.na \ #Return new df replacing one value with another
       .replace(10, 20) \
       .show()

GroupBy 

>>> df.groupBy("age")\ #Group by age, count the members in the groups
      .count() \
      .show()

Sort 
 

>>> peopledf.sort(peopledf.age.desc()).collect()
>>> df.sort("age", ascending=False).collect()
>>> df.orderBy(["age","city"],ascending=[0,1])\
     .collect()

Repartitioning 

>>> df.repartition(10)\ #df with 10 partitions
      .rdd \
      .getNumPartitions()
>>> df.coalesce(1).rdd.getNumPartitions() #df with 1 partition

Running Queries Programmatically 
 

Registering DataFrames as Views

>>> peopledf.createGlobalTempView("people")
>>> df.createTempView("customer")
>>> df.createOrReplaceTempView("customer")

Query Views

>>> df5 = spark.sql("SELECT * FROM customer").show()
>>> peopledf2 = spark.sql("SELECT * FROM global_temp.people")\
               .show()

Inspect Data 
 

>>> df.dtypes #Return df column names and data types
>>> df.show() #Display the content of df
>>> df.head() #Return first n rows
>>> df.first() #Return first row
>>> df.take(2) #Return the first n rows >>> df.schema Return the schema of df
>>> df.describe().show() #Compute summary statistics >>> df.columns Return the columns of df
>>> df.count() #Count the number of rows in df
>>> df.distinct().count() #Count the number of distinct rows in df
>>> df.printSchema() #Print the schema of df
>>> df.explain() #Print the (logical and physical) plans

Output

Data Structures 
 

 >>> rdd1 = df.rdd #Convert df into an RDD
 >>> df.toJSON().first() #Convert df into a RDD of string
 >>> df.toPandas() #Return the contents of df as Pandas DataFrame

Write & Save to Files 

>>> df.select("firstName", "city")\
       .write \
       .save("nameAndCity.parquet")
 >>> df.select("firstName", "age") \
       .write \
       .save("namesAndAges.json",format="json")

Stopping SparkSession 

>>> spark.stop()

Have this Cheat Sheet at your fingertips

Original article source at https://www.datacamp.com

#pyspark #cheatsheet #spark #dataframes #python #bigdata

How to Create a Responsive Dropdown Menu Bar with Search Field using HTML & CSS

In this guide you’ll learn how to create a Responsive Dropdown Menu Bar with Search Field using only HTML & CSS.

To create a responsive dropdown menu bar with search field using only HTML & CSS . First, you need to create two Files one HTML File and another one is CSS File.

1: First, create an HTML file with the name of index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Dropdown Menu with Search Box | Codequs</title>
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
</head>
<body>
  <div class="wrapper">
    <nav>
      <input type="checkbox" id="show-search">
      <input type="checkbox" id="show-menu">
      <label for="show-menu" class="menu-icon"><i class="fas fa-bars"></i></label>
      <div class="content">
      <div class="logo"><a href="#">CodingNepal</a></div>
        <ul class="links">
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li>
            <a href="#" class="desktop-link">Features</a>
            <input type="checkbox" id="show-features">
            <label for="show-features">Features</label>
            <ul>
              <li><a href="#">Drop Menu 1</a></li>
              <li><a href="#">Drop Menu 2</a></li>
              <li><a href="#">Drop Menu 3</a></li>
              <li><a href="#">Drop Menu 4</a></li>
            </ul>
          </li>
          <li>
            <a href="#" class="desktop-link">Services</a>
            <input type="checkbox" id="show-services">
            <label for="show-services">Services</label>
            <ul>
              <li><a href="#">Drop Menu 1</a></li>
              <li><a href="#">Drop Menu 2</a></li>
              <li><a href="#">Drop Menu 3</a></li>
              <li>
                <a href="#" class="desktop-link">More Items</a>
                <input type="checkbox" id="show-items">
                <label for="show-items">More Items</label>
                <ul>
                  <li><a href="#">Sub Menu 1</a></li>
                  <li><a href="#">Sub Menu 2</a></li>
                  <li><a href="#">Sub Menu 3</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#">Feedback</a></li>
        </ul>
      </div>
      <label for="show-search" class="search-icon"><i class="fas fa-search"></i></label>
      <form action="#" class="search-box">
        <input type="text" placeholder="Type Something to Search..." required>
        <button type="submit" class="go-icon"><i class="fas fa-long-arrow-alt-right"></i></button>
      </form>
    </nav>
  </div>
  <div class="dummy-text">
    <h2>Responsive Dropdown Menu Bar with Searchbox</h2>
    <h2>using only HTML & CSS - Flexbox</h2>
  </div>
</body>
</html>

2: Second, create a CSS file with the name of style.css

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap');
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  font-family: 'Poppins', sans-serif;
}
.wrapper{
  background: #171c24;
  position: fixed;
  width: 100%;
}
.wrapper nav{
  position: relative;
  display: flex;
  max-width: calc(100% - 200px);
  margin: 0 auto;
  height: 70px;
  align-items: center;
  justify-content: space-between;
}
nav .content{
  display: flex;
  align-items: center;
}
nav .content .links{
  margin-left: 80px;
  display: flex;
}
.content .logo a{
  color: #fff;
  font-size: 30px;
  font-weight: 600;
}
.content .links li{
  list-style: none;
  line-height: 70px;
}
.content .links li a,
.content .links li label{
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  padding: 9px 17px;
  border-radius: 5px;
  transition: all 0.3s ease;
}
.content .links li label{
  display: none;
}
.content .links li a:hover,
.content .links li label:hover{
  background: #323c4e;
}
.wrapper .search-icon,
.wrapper .menu-icon{
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 70px;
  width: 70px;
  text-align: center;
}
.wrapper .menu-icon{
  display: none;
}
.wrapper #show-search:checked ~ .search-icon i::before{
  content: "\f00d";
}
.wrapper .search-box{
  position: absolute;
  height: 100%;
  max-width: calc(100% - 50px);
  width: 100%;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}
.wrapper #show-search:checked ~ .search-box{
  opacity: 1;
  pointer-events: auto;
}
.search-box input{
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  font-size: 17px;
  color: #fff;
  background: #171c24;
  padding: 0 100px 0 15px;
}
.search-box input::placeholder{
  color: #f2f2f2;
}
.search-box .go-icon{
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 60px;
  width: 70px;
  background: #171c24;
  border: none;
  outline: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.wrapper input[type="checkbox"]{
  display: none;
}
/* Dropdown Menu code start */
.content .links ul{
  position: absolute;
  background: #171c24;
  top: 80px;
  z-index: -1;
  opacity: 0;
  visibility: hidden;
}
.content .links li:hover > ul{
  top: 70px;
  opacity: 1;
  visibility: visible;
  transition: all 0.3s ease;
}
.content .links ul li a{
  display: block;
  width: 100%;
  line-height: 30px;
  border-radius: 0px!important;
}
.content .links ul ul{
  position: absolute;
  top: 0;
  right: calc(-100% + 8px);
}
.content .links ul li{
  position: relative;
}
.content .links ul li:hover ul{
  top: 0;
}
/* Responsive code start */
@media screen and (max-width: 1250px){
  .wrapper nav{
    max-width: 100%;
    padding: 0 20px;
  }
  nav .content .links{
    margin-left: 30px;
  }
  .content .links li a{
    padding: 8px 13px;
  }
  .wrapper .search-box{
    max-width: calc(100% - 100px);
  }
  .wrapper .search-box input{
    padding: 0 100px 0 15px;
  }
}
@media screen and (max-width: 900px){
  .wrapper .menu-icon{
    display: block;
  }
  .wrapper #show-menu:checked ~ .menu-icon i::before{
    content: "\f00d";
  }
  nav .content .links{
    display: block;
    position: fixed;
    background: #14181f;
    height: 100%;
    width: 100%;
    top: 70px;
    left: -100%;
    margin-left: 0;
    max-width: 350px;
    overflow-y: auto;
    padding-bottom: 100px;
    transition: all 0.3s ease;
  }
  nav #show-menu:checked ~ .content .links{
    left: 0%;
  }
  .content .links li{
    margin: 15px 20px;
  }
  .content .links li a,
  .content .links li label{
    line-height: 40px;
    font-size: 20px;
    display: block;
    padding: 8px 18px;
    cursor: pointer;
  }
  .content .links li a.desktop-link{
    display: none;
  }
  /* dropdown responsive code start */
  .content .links ul,
  .content .links ul ul{
    position: static;
    opacity: 1;
    visibility: visible;
    background: none;
    max-height: 0px;
    overflow: hidden;
  }
  .content .links #show-features:checked ~ ul,
  .content .links #show-services:checked ~ ul,
  .content .links #show-items:checked ~ ul{
    max-height: 100vh;
  }
  .content .links ul li{
    margin: 7px 20px;
  }
  .content .links ul li a{
    font-size: 18px;
    line-height: 30px;
    border-radius: 5px!important;
  }
}
@media screen and (max-width: 400px){
  .wrapper nav{
    padding: 0 10px;
  }
  .content .logo a{
    font-size: 27px;
  }
  .wrapper .search-box{
    max-width: calc(100% - 70px);
  }
  .wrapper .search-box .go-icon{
    width: 30px;
    right: 0;
  }
  .wrapper .search-box input{
    padding-right: 30px;
  }
}
.dummy-text{
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  z-index: -1;
  padding: 0 20px;
  text-align: center;
  transform: translate(-50%, -50%);
}
.dummy-text h2{
  font-size: 45px;
  margin: 5px 0;
}

Now you’ve successfully created a Responsive Dropdown Menu Bar with Search Field using only HTML & CSS.

jon david

1649157283

Prepare Essential Exam with MS-600 Exam (2022)

Prepare Essential Exam with MS-600 Exam Exam (2022)

 

Now you have come to a point within your Microsoft Dynamics 365 profession exactly where you'd wish to have the Microsoft MS-600 certification exam. But you ought to keep in mind that Amazing MS-600 Exam Exam (2022) questions with verified answers are required to pass the MS-600 questions. So only Microsoft MS-600 pdf exam provided by RealExamCollection can help you to prepare and pass the Microsoft 365 Certified Developer Associate MS-600 exam questions. It signifies the latest MS-600 exam pdf questions would be the only way to earn the Microsoft Dynamics 365 certification. The Microsoft MS-600 exam is one of the leading source that will help you in reaching the feast of a higher ranked Microsoft Dynamics 365 career. But to truly get the Microsoft MS-600 certification exam you may have to get the valid Microsoft MS-600 practice test for the preparation.



 

Amazing MS-600 Exam Exam (2022) - A Step Closer To Better Professional Career

Authentic MS-600 exam exam (2022) given by the RealExamCollection are among the finest sources for the preparation of the Microsoft MS-600 test questions. Updated Microsoft MS-600 Exam PDF questions have been verified by the team of Microsoft authorities. Microsoft 365 Certified Developer Associate MS-600 pdf exam questions provided the complete coverage of the Microsoft MS-600 exam questions. You are able to also get the Microsoft MS-600 exam in the PDF format. Not simply this it is possible to download the demo version of Microsoft MS-600 pdf questions and MS 600 practice test to assess the good quality of the practice exam questions answers.



 

Download Here: https://www.realexamcollection.com/microsoft/ms-600-exam.html

 

Get To Understand Each Question of MS-600 PDF Exam

Also in case you are a practice enthusiast person who loves to function around the preparation of Microsoft MS-600 exam questions correct ahead of the actual Building Applications and Solutions with Microsoft 365 Core Services exam here is the difficult for you personally. You can get the Microsoft MS-600 pdf exam which can help you in preparing for the amazing MS-600 exam exam (2022) much more efficiently. RealExamCollection will be the renowned platform to prepare the Microsoft Dynamics 365 MS-600 certification exam questions. Microsoft MS-600 exam pdf questions offered by them are an ideal source of Building Applications and Solutions with Microsoft 365 Core Services questions preparation. These Microsoft MS-600 exam exam (2022) can help you to understand and pass the MS-600 questions without having  any problems with brilliant results.



 

MS-600 Exam PDF Questions - 100% Money-Back Assurance

Not just this it is possible to also get the Microsoft MS-600 exam pdf questions with 100% funds back guarantee. Total guarantee on the Microsoft 365 Certified Developer Associate MS-600 pdf exam made this attainable for you to pass the Microsoft MS-600 exam questions in the first attempt. Not simply this you are able to also get the real MS-600 exam exam (2022) with 24/7 consumer assistance. It is possible to also get the Microsoft MS-600 exam questions with 3 months totally free updates. These Building Applications and Solutions with Microsoft 365 Core Services practice exam questions answers updates make it simple for you to acquire a full update on each of the Microsoft 365 Certified Developer Associate MS-600 preparation material. In brief the RealExamCollection' real MS-600 exam exam (2022) are among the finest sources for the preparation of the Microsoft MS-600 test questions.

 

#MS-600Exam, #MicrosoftMS-600Exam, #MS-600Exam2022, #MS-600ExamPDF, #MS-600ExamQuestionAnswers, #MS-600Exam2022, #RealExamCollection

 

Houston  Sipes

Houston Sipes

1603792800

Blowing away the MS Dev Show with the awesomeness of Raygun!

Recently Raygun’s co-founder and CEO John-Daniel Trask was a guest on the awesome MS Dev Show with hosts Carl and Jason discussing a range of topics including:

  • Raygun (obviously)
  • How Google Chrome will prevent your monitors from sleeping
  • Office “Touch” for Windows
  • Cloud Platform Roadmap
  • Date and time formatting for humans
  • Raspberry Pi 2

.@Traskjd_ blows us away with the awesomeness of @Raygunio at _http://t.co/FpMPhZHTbg#devlifepic.twitter.com/PW8h0Us2qB

_— MS Dev Show (@msdevshow) _February 10, 2015

Not only is this generally a great listen for all developers, if you’re wondering how Raygun can benefit your business, save you time and improve your software quality, this episode gives a great overview of how Raygun can help you achieve that.

Listen to this episode

We think Carl and Jason are doing a great job with the show and encourage you to subscribe to the MS Dev Show for a weekly hit of developer related news and guest interviews.

#dev

中條 美冬

1639392447

PythonPillowを使用して画像を処理および操作する方法

この記事では、PythonPillowまたはPILライブラリを使用して画像を処理および操作する方法を学習します。

PillowとPIL(Python Imaging Library)は同じです。PILはPython2で使用されました。Pillowは、現在Python3と互換性のあるPILリポジトリのフォークです。このライブラリは、主に画像の開き、処理、変換に使用されます。Windows、Mac OS X、Linuxで利用できます。このライブラリを使用すると、サイズ変更、トリミング、ファイル変換、回転など、いくつかの画像操作を実行することもできます。

枕の設置

PillowをWindowsにインストールするには、ターミナルウィンドウを開き、次のコマンドを実行します-

pip install pillow

このライブラリは私の作業システムにプリインストールされているので、次のようになります-

Requirement already satisfied: pillow in c:\python37\scripts\projects\env\lib\site-packages (7.0.0)

インストールを確認してください

インストールされているバージョンを印刷することで、Pillowが正常にインストールされたことを確認できます。

import PIL
print('Pillow Version:', PIL.__version__)
(env) c:\python37\Scripts\projects>pillow1.py
Pillow Version: 7.0.0


ピロー:画像を読み込む

それでは、Pillowライブラリを使用して画像を開く方法を見てみましょう。画像処理の最も一般的なモジュールは画像モジュールです。ここでは、このモジュールのopen()メソッドを使用して画像を読み取りました。

from PIL import Image
img = Image.open('beautifultree.jpg')
img.show()

枕:色変換

Python Pillowは、色変換用のconvert()メソッドを提供します。次のコードは画像を読み取り、グレースケールに変換します。また、save()メソッドを使用して生成されたグレースケール画像を保存しました

from PIL import Image
img = Image.open('beautifultree.jpg')
img_cov = img.convert('L')
#show image
img_cov.show()
#save image
img_cov.save("bt_gray.jpg")

枕:画像のトリミング

image.crop()は、画像をトリミングするために使用されます。4つのタプル(左、上、右、下)で定義された画像から領域をトリミングします。

枕:回転画像

画像を回転するには、Image.rotate()メソッドを使用します。回転角を属性として取り、画像の回転コピーを返します。

from PIL import Image
img = Image.open('beautifultree.jpg')
cropped = img.rotate(180)
#show image
cropped.show()

ピロー:サムネイルを作成する

枕を使用してサムネイルを作成するのは非常に簡単です。サムネイルサイズを指定するタプルを取得し、画像をサムネイルに変換するthumbnail()メソッドを提供します。

 

枕:形を描く

枕モジュールを使用すると、長方形、多角形、楕円などのさまざまな形状を描画することもできます。与えられた例では、ImageDrawモジュールを使用して2つの長方形、1つのポリゴンと1つの楕円を描画しました。このモジュールは、画像オブジェクトのシンプルな2Dグラフィックスを提供します。

from PIL import Image, ImageDraw

img = Image.new('RGBA', (200, 200), 'yellow')    
idraw = ImageDraw.Draw(img)
idraw.rectangle((10, 10, 100, 100), fill='blue')
idraw.rectangle((100, 100, 250, 200), fill='cyan')

idraw.polygon([(200,10), (200, 200), (150,50)], fill = 'red')
idraw.ellipse((20, 20, 90, 90), fill = 'green', outline ='black')
img.show()