can someone help with the error with converting a json file to a data frame pls I’m trying to convert the JSON text file to a data frame but get the array same length error. I have tried double [[]] around the ‘data’ but still doesn’t work. The text file is at https://stackoverflowtez.…
Tag: pandas
how to detect a braking process in python dataframe
I have some trips, and for each trip contains different steps, the data frame looks like following: I want to know if, on a trip X, the cyclist has braked (speed has decreased by at least 30%). The problem is that the duration between every two steps is each time different. For example, in 6 seconds, the spee…
Excel VBA to Python code (Filter function)
I’m new to python. Some help would be great, thanks in advance too. I am trying to get the various average salary based on Units. In Excel, I would do =AVERAGE(FILTER(B:B,A:A=D3)). Where Column B is all the individual salaries and Column A is the various Unit. I have managed to do an array of the differ…
get intersection in single column of pandas dataframe
I have a dataframe like this: I want to add a new column ‘intersec’ and get the intersection of the Price column and its shift value. But when I use It doesn’t work, I get the following error: what should I do? My expected result is: Answer shift the price find intersect sample output
How to calculate running total per customer for previous 365 days in pandas
I am trying to calculate a running total per customer for the previous 365 days using pandas but my code isn’t working. My intended output would be something like this: date customer daily_total_per_customer rolling_total 2016-07-29 1 100 100 2016-08-01 1 50 150 2017-01-12 1 80 230 2017-10-23 1 180 260 …
How to compare each date in a cell with all the dates in a column
I have a dataframe with three columns lets say I want to compare each date in Date column with all the other dates in the Date column and only keep those rows which lie within 6 months of atleast one of all the dates. Desired Output: I have tried a couple of approches such a nested loops, but I got
Converting a CSV column into a 1D list and then into a 2D list
Hope you are well, I am fairly new in the python world and the coding world in general. I wanted to test python/panda’s powers and the usefulness of making lists. I have a column called ‘Lines’ in my csv file which reads like this: Lines A,B,C A,D,C B,C,D,E A,B,C,D,E C C,D,E Which I converte…
Pandas (How to Fix): List is actually string and the value of length is misleading
I have a dataframe with a list of years in the first column. A second column shows the number of years listed in each row. Which made me think that the contents of each cell is a pure string. And it seems that way when I checked the type: When I convert the column to list using to_list(), it shows:
Combining weeks 52 and 0 with Python Datetime
I have a Pandas DataFrame with daily data that I’m trying to group by week number to sum some columns, and I notice that when years do not begin on Sunday, the data for the week spanning the end of one year and the beginning of the next do not cleanly sum, instead being broken into two groups. My code
how can i def function for new Dataframe with Cleaned data
I have several dataframes where I need to reduce the dataframe to a time span for all of them. So that I don’t have to reduce the codeblock over and over again, I would like to write a function. Currently everything is realized without working by the following code: my approach: unfortunately this does …