When your company blocks meme generator websites (and no one reads my nested READMEs anyways)
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
library(stringr) | |
library(dplyr) | |
convert_feature_name <- function(feature_str) { | |
# Pattern that matches all possible formats | |
pattern <- "^rr_(dlnq_\\d{1,3}_\\d{1,3}|dlnq_121plus|not_dlnq)_" %>% | |
paste0("(dlnq_\\d{1,3}_\\d{1,3}|dlnq_121plus|not_dlnq|term_x)_(\\d{1,3})_(\\d{1,3})") | |
parts <- str_match(feature_str, pattern) |
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 | |
import numpy as np | |
from datetime import datetime | |
def compare_dataframes(df1, df2): | |
# Check if one object is a dataframe with datetime64[ns] dtype and the other is a list of strings | |
if isinstance(df1, pd.DataFrame) and df1.dtypes.all() == 'datetime64[ns]' and isinstance(df2, list): | |
# Convert the list of strings to datetime64[ns] format | |
df2_values = np.array([np.datetime64(datetime.strptime(date_str, '%Y-%m-%d')) for date_str in df2]) | |
elif isinstance(df2, pd.DataFrame) and df2.dtypes.all() == 'datetime64[ns]' and isinstance(df1, list): |