I would like to return each data frame from each URL appended into one single data frame. When I print it within the function, I get the result I desire. The problem is when I try assign a variable to the data frame, it only adds the final data frame. Running this function prints my desired result: But when I
Tag: dataframe
Filter table and copy to new file in Pandas (VBA-like) dynamically
I have a file (CSV) containing data that looks something like this in a table format: ID employee date value1 value2 1 a 2022-01-01 123 456 2 b 2022-01-01 123 456 3 a 2022-01-01 123 456 4 c 2022-01-01 123 456 5 d 2022-01-01 123 456 6 b 2022-01-01 123 456 7 e 2022-01-01 123 456 8 e 2022-01-01 123
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 name and then replace the values in the organization_size
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
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 used. Why is this error
Is there a way to concatenate the content of the respective cells of two different n * n data-frames within cells in pandas?
Is there a way to concatenate the content of the respective cells of two different n * n data-frames within cells in pandas? For example: Say I have two data-frames df1 and df2. df1 looks like this: Index Score_1 Score_2 Family_1 123 456 Family_2 789 1011 df2 looks like this: Index Score_1 Score_2 Family_1 A B Family_2 C D I
How to pivot a table based on the values of one column
let’s say I have the below dataframe: which looks like this: As you can see I have my wanted columns as rows in col1 and not all values have a Phone number, is there a way for me to transform this dataframe to look like this: I have tried to transpose in Excel, do a Pivot and a Pivot_Table: But
Combine dataframes based on multiple conditions in python
Table A Table B Table C These are example tables that represent dataframes that I’m going to create from seperate excel sheets. Basically there’s a many to many relationship going on and I want to be able to create a combined sheet that will roll up the “amount” total (from Table A) for each year of the item (Table B).
How to stream DataFrame using FastAPI without saving the data to csv file?
I would like to know how to stream a DataFrame using FastAPI without having to save the DataFrame to a csv file on disk. Currently, what I managed to do is to stream data from the csv file, but the speed was not very fast compared to returning a FileResponse. The /option7 below is what I’m trying to do. My
find missing datas between two tables with similar columns python
I have two dataframes with 2 similar columns “date” and “id_number” and I want to find all the id_number missing from the second table to compare. Here’s my code: import pandas as pd Answer If need compare per date and id_number use left join with indicator parameter: Or if need compare only by id_number use Series.isin: