I want to compare each list in the list of lists with the list based on the fact that each element is an interval and if that interval from “Listoflists” is included inside the interval from “List” we would get a True statement or else it would be a False one. And if possible, get in o…
Tag: pandas
How to remove quotes from Numeric data in Python
I have one numeric feature in a data frame but in excel some of the values contain quotes which need to be removed. Below table is what my data appears to be in Excel file now I want to remove quotes from last 3 rows using python. Col1 Col2 123 A 456 B 789 C “123” D “456” E “789&…
Compare 2 csv files and remove the common lines from 1st file | python
I want to compare 2 csv files master.csv and exclude.csv and remove all the matching lines based on column1 and write the final output in mater.csv file. master.csv exclude.csv Expected output (it should overwrite master.csv Tried till now Answer I believe there should be some pandas or other modules approach…
Error tokenizing data. C error: Expected x fields in line 5, saw x
I keep getting this error. I don’t even know how to identify the row that is in error as the data I am requesting is jumbled. I can’t provide a URL to the API but I will provide a sample of the first few lines of data. My code: Error: Data from API: Answer Since you don’t specify a separator
New column adding values of different columns with strings and numbers
I have a dataframe like this structure (in the real one there are more columns Game x, around 30, but for explaining I think it’s ok with these 2 columns): I need new columns for counting the minutes of any player in the columns “Game x” based in these conditions: Starting: means the player …
How can I figure out the average consecutive duration of “True” values in pandas df, per group?
With the following data, I think I want a column (DESIRED_DURATION_COL) to work out the duration (according to start_datetime) of consecutive Truths: project_id start_datetime diag_local_code DESIRED_DURATION_COL 1 2017-01-18 False 0 1 2019-04-14 True 0 1 2019-04-17 True 3 1 2019-04-19 False 0 1 2019-04-23 Tr…
Substract two row values in dataframe python
Currently I have a sort of dataframe where I want to substract value from current row from the previous one. example: df = pd.Datafame([1,4,3,5,6],columns = [“time”)]) left 1 4 3 5 6 I want to iterate over these rows and store it in a list. So the list will get like this [-3,1,-2,-1]. So far I hav…
How to get grouped cumulative duration in pandas?
I have the following data: id encounter_key datetime 1 111 2019-04-14 1 111 2019-04-14 1 111 2019-07-18 1 122 2019-09-02 2 211 2019-10-03 2 211 2020-10-03 I want to find the cumulative duration, grouped by id and encounter_key to achieve the following: id encounter_key datetime cum_duration_days 1 111 2019-04…
Scraping multiple website data from a table
I am practicing scraping website and inputting the information into a table. I imported the link, but I seem to be getting an error message based off the url. The error message I received states: I rechecked the url to run the code again, but I am still receiving this error message. Can someone please help me…
Unsure how to set up for loops and if statements to filter the data that I want:
So I have a dataframe that kinda looks like this: I want to search the dataframe and return exactly: Cutting out the top and bottom. I was able to create a function that filtered out the “Titles” of each column of data. Now I am stuck trying to filter the data out cell by cell until I reach a R…