I have a dataframe with values such as 164684564.0 (type is float 64) I just want to remove all the “.0″s from these numbers did not work and https://stackoverflow.com/a/38283006/16796767 did not work either Another thing: I don’t want to convert in scientific numbers (I did it once but I do…
Tag: pandas
perform df.loc to groupby df
I’ve a df consisted of person, origin and destination the df: I have grouped by the df with df_grouped = df.groupby([‘O’,’D’]) and match them with another dataframe, taxi. similarly, I group by the taxi with their O and D. Then I merged them after aggregating and counting the Per…
Split data frame in python based on one parameter shape
I have a data frame which is like the following : In this data frame, there are many repeated rows for example the first row is repeated more than 1000 times, and so on for the other rows when I plot the time distribution I got that figure which shows that the frequency of the time parameter My question is
Comparing two Dataframes with diff length to find difference in specific column
i have 2 dataframes have same columns with different len. the reuslt i want to get: and each df have length like this. each dataframe has column named ‘name, id, type, len’ i need to check those columns(name,type,len) in each df to compare ‘id’ column whether it has same value or not. …
Filter based on pairs within a group – if value represent at BOTH ends
Within each group there are pairs. In Group 1 for example; the pairs are (2,2),(2,4),(4,1) I want to filter these pairs based on code numbers 2 AND 4 being present at BOTH ends(not either) In group 1 for example, only (2,4) will be kept while (2,2) and (4,1) will be filtered out. Excepted Output: Answer You c…
Convert dictionary into dataframe (with repeated keys as rows)
I’m trying to convert the following dict: partlistzonesdef (has 50 keys) into a dataframe: Lets say we have the dict: How can I convert that to a dataframe like this: And so on? Answer Create a Series and transform each element of the list to a row with explode then reset_index to get expected outcome: …
Pandas: How to fill nan value for column with part of value in other columns
I Want the value in city column to be filled with first word of venue column I tried using df.city.fillna(value=df.venue.str.split()[0]) but it taking first row values to fill Thank you in advance Answer From your DataFrame : After the split() you used, we can use map to assign the first list element to the N…
Warning while adding rank column to a pandas dataframe
I have derived a dataframe using groupby. I am trying to set a new column ‘rank’ based on the ‘volume’ column using the below code. The code is working but giving a warning – Below is my code. Would appreciate guidance as I am not too much experienced in Python/ Pandas. Answer Be…
how to fix python pandas encoding issue?
I import csv table into JUPYTER NOTEBOOK, and something wrong is happening when I try to iloc a video views column (К-ть переглядів). I need to format this cell to INT type (using .astype()), but it tells me that there is an error: ValueError: invalid literal for int() with base 10: ‘380xa0891xa0555R…
How to concate a column’s sentences for same subject id in a single row in python dataframe?
if I have a dataset like- As output, I want that the Drug name with the same Subject_ID will concatenate in one row. How can I do that in Python pandas? Answer Group the dataframe by Subject_ID then call agg with ‘, ‘.join as aggregate for DRUG column, and first as aggregate for LOS column.