1

newb here, hello! I'm using map() function to iterate a list of Tickers (strings) through OHLCV download function with multiprocessing. As a result, I receive a list of dataframes.

All_coins_history = Shark_pool.map(refractor_get_history, Tickers) 

As my dataframes with history have just Dataframe[["Open", "High", "Low", "Close", "Volume"]] format, there is no way for me to know which data from All_coins_history list is for which Ticker. What is the clean way to create, for example, a dictionary instead of list, where each dataframe would have its Ticker as a key?

2
  • 1
    Please add some example input and output data, as well as more code to clarify your question (e.g. what are Shark_pool, refactor_get_history, and Tickers?). Ideally your question should contain a minimal reproducible example. Commented Sep 7, 2021 at 21:21
  • Please provide enough code so others can better understand or reproduce the problem. Commented Sep 13, 2021 at 7:41

1 Answer 1

4

Use zip() to pair up the ticker symbols with the result of the mapping, then call dict() to create the dictionary.

all_coins_history = dict(zip(Tickers, Shark_pool.map(refractor_get_history, Tickers))) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.