I am working on a data processing script that does some basic calcs from data files and sorts the data. The last piece to the puzzle is identifying if the next value is > the previous and if it is replace the next value with the previous. My df is set up as this: I want the program to identify
Tag: pandas
How to count the same rows between multiple CSV files in Pandas?
I merged 3 different CSV(D1,D2,D3) Netflow datasets and created one big dataset(df), and applied KMeans clustering to this dataset. To merge them I did not use pd.concat because of memory error and solved with Linux terminal. All these datasets contain the same column names, they have 12 columns(all numerical…
Create Pandas DataFrame from 2 tuple lists with common first elements
I currently have 2 lists of tuples, both of which have the same information on the first element of the tuple. I’m trying to see if there is a way to “Join” these two tuple lists in a dataframe based on their common elements. Something like an SQL JOIN on a common column. Lists are something…
Calling an R package function with rpy2
I’m new to R and need to pass string data from a pandas dataframe to a function in R. This function accepts nested lists of strings, such as: The code I tried two approaches: 1) That yielded KeyError: <class ‘list’> error message. 2) That yielded the error message: I checked if d is a …
How does pandas.DataFrame.replace works?
I need to remove ‘$’ symbol in ‘price’ column. I used pd.DataFrame.replace to do that. replace result. Why did nothing happen? If I use str.replace it works: str.replace Answer Try this :
How to create a 2-dimensional list with dataframes in Python
I have the following structure in my file system. So I have a folder with the name “Data” and there I have 3 subfolders “Building1”, “Building2” and “Building3”. Each of those building folders contain 3 subfolders with “Day1”, “Day2” and …
AttributeError when applying map() for formatting
Hoping someone can advise on the AttributeError I’m receiving, as I’m not sure what is wrong with the way my code is written. I’ve seen other posts dealing with “‘DataFrame’ object has no attribute”, but it wasn’t applicable to this scenario. Using Python’…
Splitting dataframe based on Floating value in python
I tried to takeout decimal values based on value present before decimal point .I have data frame like below, Expected output, How can i achieve this using pands,… Answer If data is a string: if it is a float: output:
Merge two dataframes with subheaders
So I have my first dataframe that has countries as headers and infected and death values as subheaders, then I have my second dataframe, I want to merge the dataframes so that the indicator columns become subheaders of the countries column like in df with the infected and dead subheaders. What I want to produ…
Dataframe, sum positive and negative value on specific date interval
here’s the context : I have 2 dataframes, one from a database that generate a one month series, and the second one is a download from another database, but on one year. I have make a plot where df1 and df2 are subtracted, creating a filled curve between, and I force the plot on just one month, so visual…