A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
class BackgroundImageView : UIView { | |
private let bgImage = UIImageView(forAutoLayout: ()) | |
private var blurView:UIVisualEffectView! | |
private var vibrancyView:UIVisualEffectView! | |
private var didSetupConstraints = false | |
var containerView: UIView? = nil { | |
willSet(container) { | |
removeContainerViewFromSuperview() | |
# Single selections using iloc and DataFrame | |
# Rows: | |
data.iloc[0] # first row of data frame (Aleshia Tomkiewicz) - Note a Series data type output. | |
data.iloc[1] # second row of data frame (Evan Zigomalas) | |
data.iloc[-1] # last row of data frame (Mi Richan) | |
# Columns: | |
data.iloc[:,0] # first column of data frame (first_name) | |
data.iloc[:,1] # second column of data frame (last_name) | |
data.iloc[:,-1] # last column of data frame (id) |
using Microsoft.Azure.Management.ResourceManager; | |
using Microsoft.IdentityModel.Clients.ActiveDirectory; | |
using Microsoft.PowerBI.Api.V2; | |
using Microsoft.PowerBI.Api.V2.Models; | |
using Microsoft.Rest; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; |
# List unique values in a DataFrame column | |
# h/t @makmanalp for the updated syntax! | |
df['Column Name'].unique() | |
# Convert Series datatype to numeric (will error if column has non-numeric values) | |
# h/t @makmanalp | |
pd.to_numeric(df['Column Name']) | |
# Convert Series datatype to numeric, changing non-numeric values to NaN | |
# h/t @makmanalp for the updated syntax! |
I am assuming you are here because like me, you installed a bazillion different python interpreters on mac and the whole thing is a spagetti. Today, I finally fixed my python installation. Whatever I install for python2 or python3 using pip JUST.WORKS.. My god! finally.
Here is what I had messed up, which you also probably did:
# your link goes here | |
link = "https://github.com/knightlab-analyses/qurro-mackerel-analysis/blob/master/AnalysisOutput/qurro-plot.qzv" | |
# note: this will break if a repo/organization or subfolder is named "blob" -- would be ideal to use a fancy regex | |
# to be more precise here | |
print(link.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/")) | |
# example output link: | |
# https://raw.githubusercontent.com/knightlab-analyses/qurro-mackerel-analysis/master/AnalysisOutput/qurro-plot.qzv |
# Simplified version and explanation at: https://stackoverflow.com/a/64439347/12866353 | |
import os | |
import ffmpeg | |
def compress_video(video_full_path, size_upper_bound, two_pass=True, filename_suffix='cps_'): | |
""" | |
Compress video file to max-supported size. | |
:param video_full_path: the video you want to compress. | |
:param size_upper_bound: Max video size in KB. |
import streamlit as st | |
import io | |
import contextlib | |
import sys | |
import re | |
import threading | |
class _Redirect: | |
class IOStuff(io.StringIO): |