Category "indexing"

Dataframe add new row if the index does not exist like a dictionary without checking existence

import pandas as pd a = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]] df = pd.DataFrame(a, columns=['alpha', 'one', 'two', 'three']) df.set_index(['alpha'],

Assigning to a double-indexed numpy array

I know that when assigning to a double indexed-array gives bad results because you're assigning to a view rather then to an array directly, but I cannot figure

Indexing dataframe within a loop

I'ld like to extract specific data from a log-data. In R it looks like that Data Frame I need values from Data$Time of the cases, where Data$Data_Type == "DATA"

Sequence with stopping values

This is like a regular tribonacci sequence, however, I want the sequence to stop whenever the term is at the min or max value. This is what I have started seque

PostgreSQL first query slow

I implemented cursor pagination. And for first rows it works realy well but the more I scroll down, the first query I send is slower. I run this query: SELECT *

Any efficient analogue of argsort for array of indices with NumPy?

I have an array of indices like a = [2, 4, 1, 0, 3] and I want to transform it into np.argsort(a) = [3, 2, 0, 4, 1]. The problem is that argsort has O(n*log(n))

How does mongodb decide which index to use for a query?

When a certain query is done on a mongodb collection, if there are multiple indexes that can be used to perform the query, how does mongodb choose the index for

What is the best way in numpy to use a vector of positions as indexes in a an nd array?

I have a numpy array of agents positions: positions = np.array([[row_0, col_0], [row_1, col_1], [row_2, col_2]]) I

Pyspark: Extract Json Objects from Array

I need to extract objects from an array, where there's more than one object in that array I need to repeat for every id and if the field is null then I want to

Retrieve name of column from its Index in Pandas

I have a pandas dataframe and a numpy array of values of that dataframe. I have the index of a specific column and I already have the row index of an important

how to modify already defined composite key in liquibase

I need to alter a table to modify the order of the indexes created from the composite key for the below mentioned changeset. <changeSet author="demo (generat

Is there a more efficient way to find index of an element without using list built-in functions?

We can get the index of an element in a list using the .index() function. I was wondering if there's any more efficient way to find the index without using the

Postgres array_position(array, element) sometimes 0-indexed?

Postgres method array_position(array, element), like other things in SQL, is 1-based. For example: SELECT array_position(array[4,5,6], 5) -- returns 2 But,

What's the computational complexity of .iloc[] in pandas dataframes?

I'm trying to understand what's the execution complexity of the iloc function in pandas. I read the following Stack Exchange thread (Pandas DataFrame search is

What's the computational complexity of .iloc[] in pandas dataframes?

I'm trying to understand what's the execution complexity of the iloc function in pandas. I read the following Stack Exchange thread (Pandas DataFrame search is

Mysql 8.0 "ERROR 1030 (HY000): Got error 100" when adding index to very large table

I'm attempting to add an index to a very large table (2B rows) and the command fails after a few hours with: ERROR 1030 (HY000): Got error 100 - 'InnoDB error'

Describing a numbering system that counts from x at the y position in an index

From a theoretical perspective, I'm interested in learning how one would correctly describe a numbering system that starts counting from x at the y position in

How do I plot my datetime on the x axis when this value is used as index?

I have a short question. This is my dataframe: gradient result date 2022-04-15 09:43:20 0.206947 0.10

TypeScript map over Object keys and values: Element implicitly has an 'any' type

I am trying to iterate over object keys and values but TypeScript is shouting at me that: Element implicitly has an any type because of type string can't be us

Is InnoDB index constructed in cache or disk?

I'm trying to understand InnoDB indices, but have some confusion. Are InnoDB indices (Clustered and Secondary) constructed only in cache or constructed in disk