Skip to content
Advertisement

Tag: pandas

Python – Write a row into an array into a text file

I have to work on a flat file (size > 500 Mo) and I need to create to split file on one criterion. My original file as this structure (simplified): JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum| I need to create to file depending on the first digit from ‘CompteNum’. I have started my code as well It seems ok, my concern is to create my

Python Pandas Column Formation

Is there an easy way to reformat the columns from to Thanks Answer To reorder columns dynamically based on value, here is a way to do it: This returns a dataframe with columns (axis=1) ordered based on sorted value of first row. Here is a full example using your data sample:

Operation between 2 arrays for many rows based on date

I have a dataset df_1 that looks like this: date stock A stock B stock C stock D 2020-11-01 4 8 14 30 2020-11-10 0.4 0.6 0.8 0.2 2020-11-30 6 10 20 35 2020-12-01 6 10 20 35 2020-11-31 8 12 25 0.1 And a second dataset, df_2: date output1 output2 11/2020 stock A,stock B stock C, stock D 12/2020

How to reverse a pandas series

I have a pandas series that must be flipped upside-down before I concatenate it to the main DataFrame. I can easily flip it with myseries = myseries.iloc[::-1] But when I attach it to the main DataFrame, it attaches the default series and not the flipped version. Why doesn’t the flipped series stay in place? EDIT: So my guess is that

Advertisement