d.items()
returns an iterable with key-value pairs as tuplesd.keys()
returns an iterable with all keysd.values()
returns an iterable with all valuesdict(sorted(d.items()))
returns a dict sorted by keysdict(sorted(d.items(), key=lambda x: x[1]))
returns a dict sorted by valuesd.get(key, default=None)
returns the value for a keyd.pop(key, default=None)
removes the key and returns the value for keyd.popitem()
removes the last item added and returns it as(key, value)
(LIFO)
PostgreSQL syntax
SELECT [DISTINCT] column_name
FROM table_name
WHERE condition
GROUP BY grouping_element
HAVING condition
ORDER BY expression [ ASC | DESC ]
LIMIT count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG NVIDIA_DRIVER_VERSION=570.153.02 | |
ARG NVIDIA_DRIVER_FILENAME="NVIDIA-Linux-aarch64-${NVIDIA_DRIVER_VERSION}.run" | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
ca-certificates \ | |
kmod \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DEVICES=$(camcontrol devlist | sed 's/.*,\(.*\)).*/\1/') | |
for DEV in $DEVICES; do | |
printf "%s: " "$DEV" | |
camcontrol epc "$DEV" -c status -P | |
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Input: | |
# a b c d e | |
# 0 Text Text NaN 0.0 5 | |
# 1 Text NaN 1.1.1.1 0.0 55 | |
# 2 Text.Text Text Text 0.4 555 | |
data = [ | |
{"a": "Text", "b": "Text", "d": 0, "e": 5}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t.table_schema, | |
t.table_name, | |
c.column_name | |
FROM | |
information_schema.tables t | |
INNER JOIN information_schema.columns c ON c.table_name = t.table_name | |
AND c.table_schema = t.table_schema | |
WHERE | |
c.column_name ~ 'regex' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def advanced_dataframe_union(df1, df2): | |
df1_fields = set((f.name, f.dataType) for f in df1.schema) | |
df2_fields = set((f.name, f.dataType) for f in df2.schema) | |
df2 = df2.select( | |
df2.columns | |
+ [ | |
F.lit(None).cast(datatype).alias(name) | |
for name, datatype in df1_fields.difference(df2_fields) | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.10 | |
RUN apk add --no-cache \ | |
bzip2-dev \ | |
g++ \ | |
make | |
RUN cd /tmp/ && \ | |
wget -q https://launchpad.net/pbzip2/1.1/1.1.13/+download/pbzip2-1.1.13.tar.gz && \ | |
tar -xzf pbzip2-1.1.13.tar.gz && \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pyspark.sql.types import * | |
# Define the schema | |
schema = StructType( | |
[StructField("name", StringType(), True), StructField("age", IntegerType(), True)] | |
) | |
# Write the schema | |
with open("schema.json", "w") as f: |
NewerOlder