Greetings,
I am loading in my chosen files of a special format from a folder I read in and then converted these files to dataframes. I want to store each of these files somewhere, along with some details from it. For example:
column 1 would be named 'data files' and the entries would be the loaded in files
column 2 would be named 'shares' and the entries would be some calculated values I did elsewhere in the code
column 3 would be named 'file contents' and the entries would be the contents of the files (now dataframes)
Thanks a bunch. I don't think I am keen on dictionaries since I can't easily give the columns names that aren't "key" or "value"
What is the best way to achieve this?
You really need to clarify what you are trying to do...
"I want to store each of these files somewhere" - For example, you don't store files in dataframes, you store the contents of files...
What kind of data is this? Dataframes are great for spreadsheet type data... other things, maybe not so much.
"column 2 would be named 'shares' and the entries would be some calculated values I did elsewhere in the code"
Typically a single result is stored in a single column, not multiple entries. I mean it's possible... but unless you have a good reason for doing so use multiple columns.
"column 3 would be named 'file contents' and the entries would be the contents of the files (now dataframes)"
This implies you will be storing dataframes inside of dataframes... technically possible but probably a bad idea....
Clarify what you need to do.
(Jul-20-2024, 02:50 PM)sawtooth500 Wrote: [ -> ]You really need to clarify what you are trying to do...
"I want to store each of these files somewhere" - For example, you don't store files in dataframes, you store the contents of files...
What kind of data is this? Dataframes are great for spreadsheet type data... other things, maybe not so much.
"column 2 would be named 'shares' and the entries would be some calculated values I did elsewhere in the code"
Typically a single result is stored in a single column, not multiple entries. I mean it's possible... but unless you have a good reason for doing so use multiple columns.
"column 3 would be named 'file contents' and the entries would be the contents of the files (now dataframes)"
This implies you will be storing dataframes inside of dataframes... technically possible but probably a bad idea....
Clarify what you need to do.
Thank you for responding and offering your input. I have a list of XML files that contain data from experiments. I want to load in the files (I have done this already) and then store the filenames and content in some sort of table (or any other suggestion if there is a better way). I want this 'table' to have the same columns as listed above.
I converted the XML file data to dataframes only because I thought it would be good for when I need to plot graphs from it but if you have better suggestions please let me know as I am quite new to python.
Thanks a bunch!!
(Jul-21-2024, 07:52 PM)user_404_lost_and_found Wrote: [ -> ] (Jul-20-2024, 02:50 PM)sawtooth500 Wrote: [ -> ]You really need to clarify what you are trying to do...
"I want to store each of these files somewhere" - For example, you don't store files in dataframes, you store the contents of files...
What kind of data is this? Dataframes are great for spreadsheet type data... other things, maybe not so much.
"column 2 would be named 'shares' and the entries would be some calculated values I did elsewhere in the code"
Typically a single result is stored in a single column, not multiple entries. I mean it's possible... but unless you have a good reason for doing so use multiple columns.
"column 3 would be named 'file contents' and the entries would be the contents of the files (now dataframes)"
This implies you will be storing dataframes inside of dataframes... technically possible but probably a bad idea....
Clarify what you need to do.
Thank you for responding and offering your input. I have a list of XML files that contain data from experiments. I want to load in the files (I have done this already) and then store the filenames and content in some sort of table (or any other suggestion if there is a better way). I want this 'table' to have the same columns as listed above.
I converted the XML file data to dataframes only because I thought it would be good for when I need to plot graphs from it but if you have better suggestions please let me know as I am quite new to python.
Thanks a bunch!!
So this also includes storing multiple dataframes in a 'table'
If you have your data as pandas dataframes, you can easily export the df as csv or xlsx or even json, I believe.
If you provide some sample data, that would be helpful in helping you!
Look up "How to rename the columns of a pandas dataframe".