목록전체 글 (462)
Note
SELECT * FROM 테이블 WHERE MATCH(column) AGAINST('키워드 1' in boolean mode) UNION SELECT * FROM 테이블 WHERE MATCH(column) AGAINST('키워드 2' in boolean mode); 중복없이 결과를 제공
# FULLTEXT index ALTER TABLE 테이블 ADD FULLTEXT INDEX INDEX 이름 (column) VISIBLE; # FULLTEXT index with ngram ALTER TABLE 테이블 ADD FULLTEXT INDEX INDEX 이름 (column) VISIBLE WITH PARSER NGRAM;
How to find the count of unique values in a numpy array? # Import iris keeping the text column intact url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data' iris = np.genfromtxt(url, delimiter=',', dtype='object') names = ('sepallength', 'sepalwidth', 'petallength', 'petalwidth', 'species') # Solution # Extract the species column as an array species = np.array([row.toli..
How to rename a specific columns in a dataframe? # Input df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv') # Solution # Step 1: df=df.rename(columns = {'Type':'CarType'}) # or df.columns.values[2] = "CarType" # Step 2: df.columns = df.columns.map(lambda x: x.replace('.', '_')) print(df.columns) # output Index(['Manufacturer', 'Model', 'CarType', 'Min_P..
How to replace all missing values with 0 in a numpy array? # Input url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data' iris_2d = np.genfromtxt(url, delimiter=',', dtype='float', usecols=[0,1,2,3]) iris_2d[np.random.randint(150, size=20), np.random.randint(4, size=20)] = np.nan # Solution iris_2d[np.isnan(iris_2d)] = 0 iris_2d[:4] # output array([[ 5.1, 3.5, 1.4, 0. ]..