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)
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| /** | |
| * Support custom painting on a panel in the form of | |
| * | |
| * a) images - that can be scaled, tiled or painted at original size | |
| * b) non solid painting - that can be done by using a Paint object | |
| * | |
| * Also, any component added directly to this panel will be made | |
| * non-opaque so that the custom painting can show through. | |
| */ |
| /** | |
| * A Frame class which provide a boarder-less Frame. | |
| * Also, drag the window by mouse event is implemented. | |
| * */ | |
| package com.miracleyoo.utils; | |
| import java.awt.Color; | |
| import java.awt.Point; | |
| import java.awt.event.*; |
| /** | |
| * This table utils provide the function of setting the width of each column of a Java Swing table. | |
| * It can Set one column size, or set the preferred or minimum column size. | |
| * Also, it provide the function that allow us to set different color for a certain cell in table. | |
| * */ | |
| package com.miracleyoo.utils; | |
| import javax.swing.*; | |
| import javax.swing.table.DefaultTableCellRenderer; |
| # This code is based on tutorial by slicktechies modified as needed to use oauth token from Twitch. | |
| # You can read more details at: https://www.junian.net/2017/01/how-to-record-twitch-streams.html | |
| # original code is from https://slicktechies.com/how-to-watchrecord-twitch-streams-using-livestreamer/ | |
| import requests | |
| import os | |
| import time | |
| import json | |
| import sys | |
| import subprocess |
| import argparse | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser( | |
| 'Please input the file path you want to transfer using --input=""') | |
| # Bool | |
| parser.add_argument( | |
| '--compress', | |
| action='store_true', |
| import chardet | |
| with open(input_path, 'rb') as f: | |
| s = f.read() | |
| chatest = chardet.detect(s) | |
| # print(chatest) | |
| with open(input_path,"r",encoding=chatest["encoding"]) as f: | |
| lines = f.read() | |
| with open(output_path, "w+", encoding=chatest["encoding"]) as fw: |
| import functools | |
| import time | |
| class Timer(object): | |
| def __init__(self, name=None): | |
| self.name = name | |
| def __enter__(self): | |
| self.t_start = time.time() |
| import datetime | |
| datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") |