I’ve a simulation result for an antenna result as it can be found in here You can see that I need to reshape this data so three things happen: The headers are kept on the format Var(extraInfo)[unit] where the parenthesis can be sometimes optional as seen from the first column and third column The second…
Tag: pandas
Python pandas trying to get Cummin but get a zero value
I want to use cummin but it doesnt work, It shows zero, cummax work well. my code: original df: my result : Answer It is expected, because after shift first value is 0, so after cummin is here always 0 (until negative value): Remove fill_value=0 for NaN instead 0 for first value in Series.shift, last if neces…
How to solve “UnicodeDecodeError ” wile using pandas to automate +100 .csv files?
I have been trying to write a For loop to store all of the CSV files in a directory into one. The files in that directory were produced by another pandas program I wrote, and I have used “group.to_csv(f’data3/{station}.csv’, index = False, encoding = “utf-8″)” for them to m…
Problem combining Date and Time Column using python pandas
First of all: I’m sorry if that’s a repost, but I did not found a similiar question. I have a DataFrame containing one column with values, one with timestamps and one with a corresponding date. As far as I understood I have to use pd.to_datetime for column ‘Date’ and pd.to_timedelta fo…
How to find the most frequent appearence in one column for different values in a different column of a grouped dataframe?
The question is not so clear I guess, so here is an example: given a dataframe: company_name company_size company_acitivity 7 eleven 5 restaurant 7 eleven 5 supermarket 7 eleven 10 supermarket goldman sachs 100 bank goldman sachs 200 restaurant goldman sachs 200 bank I want to group the dataframe by company n…
Read through a text file and output to a dataframe by Python
I have an text file as below format. I want to read through all the records in the file and output in a dataframe. Expected output: There will be two types of trans description. Code I am trying as below, but it only works for one line of the text file. How can I modify to read through all the
Pandas – Create a DF with all the values from 2 columns
I have a DF similar to the below. What I want to do is to take the SKUs from SKU1 and SKU2 and create a separate DF with all possible SKU values. It seems simple but I’m having some trouble. DF SKU1 SKU2 66FS 6dhs b87w ssftv yy5hf y346d Desired Output All_SKUs 66FS b87w yy5hf 6dhs ssftv y346d Answer If
Comparing two data frames with different columns and getting the differences
I have a similar question as here Comparing two data frames and getting the differences But columns in df1 is a subset of columns in df2. I would like to get the difference the two df by comparing those columns in common only. So the result I expect to get is Is there a way to do so? Any help
Why does pandas rolling apply throw ValueError when used on axis=1?
Overview I am getting a ValueError when trying to apply a simple function over a dataframe with axis=1 (details below). It looks like it is trying to unpack the output into the columns of the dataframe instead of rows. The problem seems to be related to the apply() specifically, and only occurs when axis=1 is…
Python/Pyodbc/SQL – Updating a table and setting a field to a CSV File
I am trying to use pyodbc to update an existing MS Access database table with a very long multiline string. The string is actually a csv that has been turned into a string. The query I am trying to use to update the table is as follows: The full printed statement looks as follows: However this does not seem t…