Skip to content
Advertisement

Tag: pandas

python code on Heroku errors where it works locally

I am getting too many errors on Heroku, so any print statements are not showing up in logs. This code works fine locally (python on windows 10) but wont work on Heroku, where it tells me there is nothing to concat… I have checked the storetx folder on Heroku and the tastyworks_tx*.csv files are present and I have other functions

Create a DataFrame from list in lists (Pandas)

I´m having trouble creating a dataframe on my list. The list contains four columns, but instead it says on presente one column with data: The list itself is presented in this way: I know there is something happening due to the double [], but i can´t figure it out. Can´t someone help me? Here is the code so far: Answer

Create new column with conditions in Pandas

I have two dataframes which are: The first dataframe could be created with the Python code: and the second dataframe: I want to create a second column in the first dataframe and the value of each Date in the new column will be the value of the first Date in the second dataframe equal to or earlier than the Date

Filtering out rows based on other rows using pandas

I have a dataframe that looks like this: I can’t seem to figure out a way to filter out certain rows based on the following condition: If there are two entries under the same companyId, as is the case for 198236 and 153421, I want to keep only the entry where type is actual. If there is only one entry

Pandas how to mege the list of columns with NaN?

I want to merge the columns that have the list objects. The problem is, I need to remove duplicate parts. How am I able to get the columns that have the merged list like below? Source: Expected: Answer You can use this code regardless of the size(column lengths, row lengths) of dataframes. I edited some codes cuz I didn’t realize

How to keep dtypes when reading a parquet file(read_parquet()) in pandas?

Code: As you can see here, [{‘b’: 1}] becomes [{‘b’: 1.0}]. How can I keep dtypes even in reading the parquet file? Answer You can try to use pyarrow.parquet.read_table and pyarrow.Table.to_pandas with integer_object_nulls (see the doc) a 0 [{‘b’: 1}] 1 [{‘b’: None}] On the other hand, it looks like pandas.read_parquet with use_nullable_dtypes doesn’t work. a 0 [{‘b’: 1.0}] 1

Advertisement