Pandas or Numpy

Chris Angelico rosuav at gmail.com
Sun Jan 23 12:25:04 EST 2022


On Mon, 24 Jan 2022 at 04:10, Tobiah <toby at tobiah.org> wrote:
>
> I know very little about either.  I need to handle score input files
> for Csound.  Each line is a list of floating point values where each
> column has a particular meaning to the program.
>
> I need to compose large (hundreds, thousands, maybe millions) lists
> and be able to do math on, or possibly sort by various columns, among other
> operations.  A common requirement would be to do the same math operation
> on each value in a column, or redistribute the values according to an
> exponential curve, etc.
>
> One wrinkle is that the first column of a Csound score is actually a
> single character.  I was thinking if the data types all had to be the
> same, then I'd make a translation table or just use the ascii value
> of the character, but if I could mix types that might be a smidge better.
>
> It seems like both libraries are possible choices.  Would one
> be the obvious choice for me?
>

I'm not an expert, but that sounds like a job for Pandas to me. It's
excellent at handling tabular data, and yes, it's fine with a mixture
of types. Everything else you've described should work fine (not sure
how to redistribute on an exponential curve, but I'm sure it's not
hard).

BTW, Pandas is built on top of Numpy, so it's kinda "both".

ChrisA


More information about the Python-list mailing list