Getting dictionary from a manager as global variable











up vote
0
down vote

favorite












I'm trying the following code before main



manager = Manager()
general_d = manager.dict()


Then in main
I define the following



  p = Pool(4)  # however many process you want to spawn
p.map(proc_file, directoary_names)

def proc_file(directoary_names):
try:
process_data(directoary_names)
except KeyboardInterrupt:
pass


The problem is I get frozen exception is not going to be frozen to produce an executable.''')



The main problem is I'm processing many files and I'm getting results from each file, so the problem how would I get the results for example from sensors ( s1 to s8) with time stamps for each sensor and merge them in order of time stamps...



A pseudo code would be helpfull.



In process data, I process the file, read it's data, then I put the results into global lists



             S1.append(df_conv['C_strain_COY'].median())
S2.append(df_conv['C_strain_CUY'].median())
S3.append(df_conv['C_strain_ROX'].median())
S4.append(df_conv['C_strain_CUX'].median())
S5.append(df_conv['C_strain_CMX'].median())
S6.append(df_conv['C_strain_COX'].median())
S7.append(df_conv['C_strain_LOX'].median())

T1.append(df_conv['C_temp_CUY'].median())
T2.append(df_conv['C_temp_COY'].median())
T3.append(df_conv['C_temp_CUX'].median())
T4.append(df_conv['C_temp_CMX'].median())
T5.append(df_conv['C_temp_COX'].median())









share|improve this question
























  • Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
    – randomwalker
    Nov 8 at 8:51












  • @randomwalker I already modified the post to clarify what does process data do
    – andre ahmed
    Nov 8 at 8:56










  • Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
    – randomwalker
    Nov 8 at 9:02












  • @randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
    – andre ahmed
    Nov 8 at 9:19










  • would you show a pseudo code as an answer for your idea ?
    – andre ahmed
    Nov 8 at 9:19















up vote
0
down vote

favorite












I'm trying the following code before main



manager = Manager()
general_d = manager.dict()


Then in main
I define the following



  p = Pool(4)  # however many process you want to spawn
p.map(proc_file, directoary_names)

def proc_file(directoary_names):
try:
process_data(directoary_names)
except KeyboardInterrupt:
pass


The problem is I get frozen exception is not going to be frozen to produce an executable.''')



The main problem is I'm processing many files and I'm getting results from each file, so the problem how would I get the results for example from sensors ( s1 to s8) with time stamps for each sensor and merge them in order of time stamps...



A pseudo code would be helpfull.



In process data, I process the file, read it's data, then I put the results into global lists



             S1.append(df_conv['C_strain_COY'].median())
S2.append(df_conv['C_strain_CUY'].median())
S3.append(df_conv['C_strain_ROX'].median())
S4.append(df_conv['C_strain_CUX'].median())
S5.append(df_conv['C_strain_CMX'].median())
S6.append(df_conv['C_strain_COX'].median())
S7.append(df_conv['C_strain_LOX'].median())

T1.append(df_conv['C_temp_CUY'].median())
T2.append(df_conv['C_temp_COY'].median())
T3.append(df_conv['C_temp_CUX'].median())
T4.append(df_conv['C_temp_CMX'].median())
T5.append(df_conv['C_temp_COX'].median())









share|improve this question
























  • Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
    – randomwalker
    Nov 8 at 8:51












  • @randomwalker I already modified the post to clarify what does process data do
    – andre ahmed
    Nov 8 at 8:56










  • Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
    – randomwalker
    Nov 8 at 9:02












  • @randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
    – andre ahmed
    Nov 8 at 9:19










  • would you show a pseudo code as an answer for your idea ?
    – andre ahmed
    Nov 8 at 9:19













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying the following code before main



manager = Manager()
general_d = manager.dict()


Then in main
I define the following



  p = Pool(4)  # however many process you want to spawn
p.map(proc_file, directoary_names)

def proc_file(directoary_names):
try:
process_data(directoary_names)
except KeyboardInterrupt:
pass


The problem is I get frozen exception is not going to be frozen to produce an executable.''')



The main problem is I'm processing many files and I'm getting results from each file, so the problem how would I get the results for example from sensors ( s1 to s8) with time stamps for each sensor and merge them in order of time stamps...



A pseudo code would be helpfull.



In process data, I process the file, read it's data, then I put the results into global lists



             S1.append(df_conv['C_strain_COY'].median())
S2.append(df_conv['C_strain_CUY'].median())
S3.append(df_conv['C_strain_ROX'].median())
S4.append(df_conv['C_strain_CUX'].median())
S5.append(df_conv['C_strain_CMX'].median())
S6.append(df_conv['C_strain_COX'].median())
S7.append(df_conv['C_strain_LOX'].median())

T1.append(df_conv['C_temp_CUY'].median())
T2.append(df_conv['C_temp_COY'].median())
T3.append(df_conv['C_temp_CUX'].median())
T4.append(df_conv['C_temp_CMX'].median())
T5.append(df_conv['C_temp_COX'].median())









share|improve this question















I'm trying the following code before main



manager = Manager()
general_d = manager.dict()


Then in main
I define the following



  p = Pool(4)  # however many process you want to spawn
p.map(proc_file, directoary_names)

def proc_file(directoary_names):
try:
process_data(directoary_names)
except KeyboardInterrupt:
pass


The problem is I get frozen exception is not going to be frozen to produce an executable.''')



The main problem is I'm processing many files and I'm getting results from each file, so the problem how would I get the results for example from sensors ( s1 to s8) with time stamps for each sensor and merge them in order of time stamps...



A pseudo code would be helpfull.



In process data, I process the file, read it's data, then I put the results into global lists



             S1.append(df_conv['C_strain_COY'].median())
S2.append(df_conv['C_strain_CUY'].median())
S3.append(df_conv['C_strain_ROX'].median())
S4.append(df_conv['C_strain_CUX'].median())
S5.append(df_conv['C_strain_CMX'].median())
S6.append(df_conv['C_strain_COX'].median())
S7.append(df_conv['C_strain_LOX'].median())

T1.append(df_conv['C_temp_CUY'].median())
T2.append(df_conv['C_temp_COY'].median())
T3.append(df_conv['C_temp_CUX'].median())
T4.append(df_conv['C_temp_CMX'].median())
T5.append(df_conv['C_temp_COX'].median())






python multithreading






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 8:55

























asked Nov 8 at 8:34









andre ahmed

257




257












  • Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
    – randomwalker
    Nov 8 at 8:51












  • @randomwalker I already modified the post to clarify what does process data do
    – andre ahmed
    Nov 8 at 8:56










  • Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
    – randomwalker
    Nov 8 at 9:02












  • @randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
    – andre ahmed
    Nov 8 at 9:19










  • would you show a pseudo code as an answer for your idea ?
    – andre ahmed
    Nov 8 at 9:19


















  • Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
    – randomwalker
    Nov 8 at 8:51












  • @randomwalker I already modified the post to clarify what does process data do
    – andre ahmed
    Nov 8 at 8:56










  • Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
    – randomwalker
    Nov 8 at 9:02












  • @randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
    – andre ahmed
    Nov 8 at 9:19










  • would you show a pseudo code as an answer for your idea ?
    – andre ahmed
    Nov 8 at 9:19
















Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
– randomwalker
Nov 8 at 8:51






Could you clarify "The problem is I get frozen exception is not going to be frozen to produce an executable.''')" ? What does process_data do, does it return e.g. a dict?
– randomwalker
Nov 8 at 8:51














@randomwalker I already modified the post to clarify what does process data do
– andre ahmed
Nov 8 at 8:56




@randomwalker I already modified the post to clarify what does process data do
– andre ahmed
Nov 8 at 8:56












Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
– randomwalker
Nov 8 at 9:02






Given the lists S1, ..., S7, which contain DataFrames, you could use pd.concat to get a DataFrame for each sensor (pandas.pydata.org/pandas-docs/stable/merging.html). This DataFrame can then be sorted along the timestamp column. If you also want to merge all sensor data to a single dataframe there is pd.merge, pd.merge_asof.
– randomwalker
Nov 8 at 9:02














@randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
– andre ahmed
Nov 8 at 9:19




@randomwalker thanks for your suggestions, but should I need the a dictionary from a manager to do that ? or the current lists with merging and the stuff is only what is needed ?
– andre ahmed
Nov 8 at 9:19












would you show a pseudo code as an answer for your idea ?
– andre ahmed
Nov 8 at 9:19




would you show a pseudo code as an answer for your idea ?
– andre ahmed
Nov 8 at 9:19












1 Answer
1






active

oldest

votes

















up vote
1
down vote













Say S1 to S7 are lists of Pandas DataFrames, each containing data of a specific sensor and an according timestamp for each data entry.



import pandas as pd



Create a joint DataFrame for each sensor



df_S1 = pd.concat(S1)



Sort these DataFrame along the timestamp axis



df_S1 = df_S1.sort_values(by='timestamps')



Now, if you want to merge all sensors together in a single DataFrame, checkout Pandas' tutorial to decide which function you need (e.g. pd.merge or pd.merge_asof). If you go with pd.merge, you can loop over df_S1, ..., df_S7, since pd.merge supports only merging two DataFrames.






share|improve this answer





















  • The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
    – andre ahmed
    Nov 8 at 10:05












  • pastebin.com/e0ENQYKB take a look here please. Voted up
    – andre ahmed
    Nov 8 at 10:06








  • 1




    Is there a timestamp for each file or does every entry in the file has its own timestamp?
    – randomwalker
    Nov 8 at 10:13










  • if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
    – andre ahmed
    Nov 8 at 10:18










  • Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
    – andre ahmed
    Nov 8 at 12:17











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204020%2fgetting-dictionary-from-a-manager-as-global-variable%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Say S1 to S7 are lists of Pandas DataFrames, each containing data of a specific sensor and an according timestamp for each data entry.



import pandas as pd



Create a joint DataFrame for each sensor



df_S1 = pd.concat(S1)



Sort these DataFrame along the timestamp axis



df_S1 = df_S1.sort_values(by='timestamps')



Now, if you want to merge all sensors together in a single DataFrame, checkout Pandas' tutorial to decide which function you need (e.g. pd.merge or pd.merge_asof). If you go with pd.merge, you can loop over df_S1, ..., df_S7, since pd.merge supports only merging two DataFrames.






share|improve this answer





















  • The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
    – andre ahmed
    Nov 8 at 10:05












  • pastebin.com/e0ENQYKB take a look here please. Voted up
    – andre ahmed
    Nov 8 at 10:06








  • 1




    Is there a timestamp for each file or does every entry in the file has its own timestamp?
    – randomwalker
    Nov 8 at 10:13










  • if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
    – andre ahmed
    Nov 8 at 10:18










  • Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
    – andre ahmed
    Nov 8 at 12:17















up vote
1
down vote













Say S1 to S7 are lists of Pandas DataFrames, each containing data of a specific sensor and an according timestamp for each data entry.



import pandas as pd



Create a joint DataFrame for each sensor



df_S1 = pd.concat(S1)



Sort these DataFrame along the timestamp axis



df_S1 = df_S1.sort_values(by='timestamps')



Now, if you want to merge all sensors together in a single DataFrame, checkout Pandas' tutorial to decide which function you need (e.g. pd.merge or pd.merge_asof). If you go with pd.merge, you can loop over df_S1, ..., df_S7, since pd.merge supports only merging two DataFrames.






share|improve this answer





















  • The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
    – andre ahmed
    Nov 8 at 10:05












  • pastebin.com/e0ENQYKB take a look here please. Voted up
    – andre ahmed
    Nov 8 at 10:06








  • 1




    Is there a timestamp for each file or does every entry in the file has its own timestamp?
    – randomwalker
    Nov 8 at 10:13










  • if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
    – andre ahmed
    Nov 8 at 10:18










  • Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
    – andre ahmed
    Nov 8 at 12:17













up vote
1
down vote










up vote
1
down vote









Say S1 to S7 are lists of Pandas DataFrames, each containing data of a specific sensor and an according timestamp for each data entry.



import pandas as pd



Create a joint DataFrame for each sensor



df_S1 = pd.concat(S1)



Sort these DataFrame along the timestamp axis



df_S1 = df_S1.sort_values(by='timestamps')



Now, if you want to merge all sensors together in a single DataFrame, checkout Pandas' tutorial to decide which function you need (e.g. pd.merge or pd.merge_asof). If you go with pd.merge, you can loop over df_S1, ..., df_S7, since pd.merge supports only merging two DataFrames.






share|improve this answer












Say S1 to S7 are lists of Pandas DataFrames, each containing data of a specific sensor and an according timestamp for each data entry.



import pandas as pd



Create a joint DataFrame for each sensor



df_S1 = pd.concat(S1)



Sort these DataFrame along the timestamp axis



df_S1 = df_S1.sort_values(by='timestamps')



Now, if you want to merge all sensors together in a single DataFrame, checkout Pandas' tutorial to decide which function you need (e.g. pd.merge or pd.merge_asof). If you go with pd.merge, you can loop over df_S1, ..., df_S7, since pd.merge supports only merging two DataFrames.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 9:35









randomwalker

845




845












  • The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
    – andre ahmed
    Nov 8 at 10:05












  • pastebin.com/e0ENQYKB take a look here please. Voted up
    – andre ahmed
    Nov 8 at 10:06








  • 1




    Is there a timestamp for each file or does every entry in the file has its own timestamp?
    – randomwalker
    Nov 8 at 10:13










  • if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
    – andre ahmed
    Nov 8 at 10:18










  • Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
    – andre ahmed
    Nov 8 at 12:17


















  • The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
    – andre ahmed
    Nov 8 at 10:05












  • pastebin.com/e0ENQYKB take a look here please. Voted up
    – andre ahmed
    Nov 8 at 10:06








  • 1




    Is there a timestamp for each file or does every entry in the file has its own timestamp?
    – randomwalker
    Nov 8 at 10:13










  • if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
    – andre ahmed
    Nov 8 at 10:18










  • Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
    – andre ahmed
    Nov 8 at 12:17
















The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
– andre ahmed
Nov 8 at 10:05






The problem is timestamps are generated before processing the data.. as the function process_data doesn't accept more than one iterable, how to solve that issue
– andre ahmed
Nov 8 at 10:05














pastebin.com/e0ENQYKB take a look here please. Voted up
– andre ahmed
Nov 8 at 10:06






pastebin.com/e0ENQYKB take a look here please. Voted up
– andre ahmed
Nov 8 at 10:06






1




1




Is there a timestamp for each file or does every entry in the file has its own timestamp?
– randomwalker
Nov 8 at 10:13




Is there a timestamp for each file or does every entry in the file has its own timestamp?
– randomwalker
Nov 8 at 10:13












if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
– andre ahmed
Nov 8 at 10:18




if you look at the code, you will there is a timestamp for each file.. Please take a look at the code... I don't know how to generate the Sx and Tx as dataframes
– andre ahmed
Nov 8 at 10:18












Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
– andre ahmed
Nov 8 at 12:17




Can you tell me how to construct S1 to S7 ? as list od pandas dataframes ?
– andre ahmed
Nov 8 at 12:17


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204020%2fgetting-dictionary-from-a-manager-as-global-variable%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Landwehr

Reims

Schenkenzell