I have a python file which I have called Pre_Processing_File.py, this file has the function pre_Processing which loads in a text file and creates 3 data frames; userListing_DF,PrivAcc,allAccountsDF, this function then returns the 3 DFs. What I want to do is create another script and import the 3 DFs from the pre_Processing.py file, I have created a script called call_DFs
Tag: dataframe
How to match multiple columns from two dataframes that have different sizes?
One of the solutions that is similar is found in here where the asker only have a single dataframe and their requirements was to match a fixed string value: result = df.loc[(df[‘Col1′] ==’Team2’) & (df[‘Col2′]==’Medium’), ‘Col3’].values[0] However, the problem I encountered with the .loc method is that it requires the 2 dataframes to have the same size because it will
Combining unique elements of a DataFrame in a list
I’ll try to ask my question as clearly as possible. I have the following DataFrame which looks like this Now I want to keep values unique to each player only once. Ideally in a list, but that’s not a big deal. For example, player A and B play soccer so I don’t want soccer in the output. tennis appears twice,
Create new pd dataframe column that gives a date based on day and week starting data
I have a pandas dataframe that has two columns, the first column is ‘Week Starting’ and the other is ‘Day’. I wanna create a new column that uses the data from the other two columns to give a full date. For example, from the table below, the first entry of the new column should be 5/04/2021 and the second should
Error: ‘str’ object has no attribute ‘shape’ while trying to covert datetime in a dataframe
Consider a I have a column called ‘test’ of a dataframe. The column elements are like this: I want to make the each column elements of the dataframe as 2016-04-01. Based on this I have written a code which is working fine in spyder but when I am trying to apply it to Jupyter Notebook it is showing some error
How to color dataframe based on each group?
I have a dataframe as below I want to color the dataframe for each Variable a different color for all columns. In the above figure, the selected variables should have one color, the below variable type should in another color etc., How can I color the dataframe in different colors for each Variable groups? Answer You can try the below
Get the index of a datatime in a dataframe pandas
for row in data[‘column_name’]: if row.date() < datetime.today().date(): print(row,????) I was not able to get the index of a datatime of a specific column in a dataframe. I used this code and i want to return with the row the index of the row. Could anyone help me please? Answer You can try with something as follows
How to optimize time while converting list to dataframe?(Part II)
I didn’t get any proper answers to my previous question: How to optimize time while converting list to dataframe? Let me explain the example more: Let’s consider the data frame more precisely as I want the output dataframe when converted to csv as The character PH,AG, AD,N should not be mapped. It can be any character. This works fine while
Converting list to comma separated integers to be substituted in IN clause of Pandas dataframe query
I have a list of integers that contains EMPI_ID I have a variable that defines the SQL query Columns for the dataframe: When I try to convert them to comma separated integer values, the sql_string hold Str values and is failing to fetch the data from database. Please advise how i can change the query to substitute the IN clause
What is the best way to filter rows of one dataframe based on column entries of another dataframe
I have two dataframes in python, one called DayList, with these columns: OrderNr Powder Variant Quantity DueDate, and another one called Planning, with these columns: Order Start End Day Powder Variant Task. Both dataframes will have multiple lines with specific combinations, the column entries for Powder and Variant will be an integer, I want to filter the dataframe DayList into