I have a dictionary of a static structure: I will need to record data a few extra keys deep to the same depth, so somewhat uniform. Example Dictionary: I want a DataFrame of this structure: Example Desired DataFrame: Where all Child Values are either a list object of strings or a string object. From researchi…
Tag: dataframe
Concat multiple small DataFrames as one big DataFrame
I’m trying to make a large DataFrame from a bunch of smaller DF. so I’ve look at multiple sites a nd they all mention to use the pd.concat() method and create an empty DataFrame. I did, however when I print inside my for loop I still get data as if it was still sectioned by individual DataFrame, a…
How to look for specific values and return an index in a dataframe?
I have a DataFrame that looks like this: So I have a pair of u and v values (the last two columns). So what I want to ask is, if for example I have a value of u = 279 and a value of v = -108, my output would be Index = 2, is there a way to do
How to transform such a long to wide table?
I am trying to transform this long dataframe to the wide dataframe with the following logic, the numbering of the columns is not important, what is important that the format stays this way as then I would need to use it for apriori algorithm. Answer There are many different ways to reshape a pandas data frame…
Pandas: Add column information based on length of another dataframe
I have two data frames. I want to add the columns from the second data frame to the first one by matching the column information in data frame 1. The first data frame: dd The second dataframe: df There are 61 unique items in column libcs in dataframe1 and 61 rows in the second data frame. I want to merge
Check if value in pandas dataframe is within any two values of two other columns in another dataframe
I have two dataframes of different length. dfSamples (63012375 rows) and dfFixations (200000 rows). I would like to check each value in dfSamples if it is within any two ranges given in dfFixations and then assign a label to this value. I have found this: Check if value in a dataframe is between two values in…
Unique keywords on the column
I’m new to pandas and I have a question. I have a dataframe like and I should remove duplicates on “Keywords” column, no matter if the duplicates are on the same row or on 3 different rows. No matter if it is written “warehouse” or “Warehouse” Everything value duplica…
Python: Save variables-names and use them later in a loop
I downloaded DataFrames (depending on how many assets are in the variable “assets”) and created for each one its own variable by using globals(). Now, I require a loop to pick up each created variable, to perform other tasks with these variables. Before this, I need to “save” the creat…
How to rename values in column having a specific separation symbols?
Values in my DataFrame look like this: I want to remove everything in values of id column after _numeric. So desired result must look like: How to do that? I know that str.replace() can be used, but I don’t understand how to write regular expression part in it. Answer You can use regex(re.search) to fin…
Pandas select dataframe rows between multiple date times
Current df: I have the df with Date and a float number. Date is the index and is unique. I would like to create a new df based on the dates found in the next df. I expect to get: In other word I want to filter the initial df and find all rows between all the dates found in