0

After reading a series of files I create a dataframe with 7 columns:

<class 'pandas.core.frame.DataFrame'>
Int64Index: 756 entries, 0 to 755

Data columns:

Fr(Hz)        756  non-null values

res_ohm*m     756  non-null values

phase_mrad    756  non-null values

ImC_S/m       756  non-null values

Rm_S/m        756  non-null values

C_el          756  non-null values

date          756  non-null values

dtypes: float64(6), object(1)

then I want to group the date by column 6 (C_el) which has 12 variables:

Pairs = = data_set.groupby('C_el')

each group now contains data that are multiple of 21 (that means each 21 lines I have a new unique dataset) - 21 refers to the column 1 (Fr(Hz) where I am using 21 frequencies for each dataset

what I want to do is to create an x, y scattered plot - on X axis is column 1 (Fr(Hz), and on Y axis is column 3 (phase_mrad) - each dataset will have the 21 unique poits of frequency, and then I want to add all available datasets on the same plot, using different color

the final step, is to repeat this for the 11 remaining groups (as defined in an aearlier step)

sample datasets are here (A12) currently I do this very ugly in numpy multiple_datasets

2
  • I really have no idea what you are asking, could you try to clean this up a bit? There is no need to mark new things as 'UPDATE', delete the old/irrelevant stuff and boil down what is left to the essence of your question. Commented Apr 3, 2013 at 0:35
  • @tcaswell - this is a fair comment, I will clear and update the question today Commented Apr 4, 2013 at 15:17

1 Answer 1

1

I don't know if this will really satisfy your requirement, but I think groupby could do you a lot of favour. For instance, instead of the code example that you provided, you could instead do this:

for key, group in data_set.groupby('C_el'):
   # -- define the filename, path, etc..
   # e.g. filename = key
   group.to_csv(filename, sep=' ')

See also the documentation here. Sorry I can't help you out with more details, but I hope it helps to proceed somewhat.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for the suggestion - I can see how this can help with my first problem (saving the data) - and it looks a way more elegant way! - it is not that straight forward to me how to implement it, but will do it as an exercise - thanks!!!!
Ok, did the above for saving data - really more elegant, and significantly less rows of code.. see updated code
@Dimitris If this solved your problem please accept it (the big gray checkmark on the left)!
@tcaswell no, it actualy didn't solve my problem - helped me in better organizing the data, but my problem (how to plot efficiently) is still unresolved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.