Python Financial OHLC with Data_Time data conversion: List Array to Pandas and appending column name for each
I have this raw data retreive from some source as list array enclosed by ()
[('2018-10-13T21:00:00.000000000', 71.457, 72.675, 68.45 , 69.252, 71.51 , 72.725, 68.505, 69.31 , 507708)
('2018-10-20T21:00:00.000000000', 69.252, 69.806, 65.72 , 67.685, 69.31 , 69.855, 65.77 , 67.74 , 389174)
('2018-10-27T21:00:00.000000000', 67.685, 67.924, 62.61 , 62.855, 67.74 , 67.975, 62.665, 62.905, 454709)
('2018-11-03T21:00:00.000000000', 62.855, 64.115, 59.244, 59.815, 62.905, 64.165, 59.295, 59.87 , 858696)
('2018-11-10T22:00:00.000000000', 59.815, 61.262, 54.732, 56.125, 59.87 , 61.315, 54.787, 56.175, 440074)]
I want to make this as pandas data frame and add column name ,using the for loop this is achieved with desired output ,however how to do this without for loop directly using pandas built in resources and how to store this is in pandas object.
for row in history:
print("{0:s}, {1:,.5f}, {2:,.5f}, {3:,.5f}, {4:,.5f}, {5:d}".format(
pd.to_datetime(str(row['Date'])).strftime(date_format), row['BidOpen'], row['BidHigh'],row['BidLow'], row['BidClose'], row['Volume']))
output : Here T in between the Date and Time removed and float ,decimal also take care .If not other solution how this can be stored in pandas object.
Date, BidOpen, BidHigh, BidLow, BidClose, Volume
13.10.2018 21:00:00, 71.45700, 72.67500, 68.45000, 69.25200, 507708
20.10.2018 21:00:00, 69.25200, 69.80600, 65.72000, 67.68500, 389174
27.10.2018 21:00:00, 67.68500, 67.92400, 62.61000, 62.85500, 454709
03.11.2018 21:00:00, 62.85500, 64.11500, 59.24400, 59.81500, 858696
10.11.2018 22:00:00, 59.81500, 61.26200, 54.73200, 56.12500, 440074
python pandas list dataframe
add a comment |
I have this raw data retreive from some source as list array enclosed by ()
[('2018-10-13T21:00:00.000000000', 71.457, 72.675, 68.45 , 69.252, 71.51 , 72.725, 68.505, 69.31 , 507708)
('2018-10-20T21:00:00.000000000', 69.252, 69.806, 65.72 , 67.685, 69.31 , 69.855, 65.77 , 67.74 , 389174)
('2018-10-27T21:00:00.000000000', 67.685, 67.924, 62.61 , 62.855, 67.74 , 67.975, 62.665, 62.905, 454709)
('2018-11-03T21:00:00.000000000', 62.855, 64.115, 59.244, 59.815, 62.905, 64.165, 59.295, 59.87 , 858696)
('2018-11-10T22:00:00.000000000', 59.815, 61.262, 54.732, 56.125, 59.87 , 61.315, 54.787, 56.175, 440074)]
I want to make this as pandas data frame and add column name ,using the for loop this is achieved with desired output ,however how to do this without for loop directly using pandas built in resources and how to store this is in pandas object.
for row in history:
print("{0:s}, {1:,.5f}, {2:,.5f}, {3:,.5f}, {4:,.5f}, {5:d}".format(
pd.to_datetime(str(row['Date'])).strftime(date_format), row['BidOpen'], row['BidHigh'],row['BidLow'], row['BidClose'], row['Volume']))
output : Here T in between the Date and Time removed and float ,decimal also take care .If not other solution how this can be stored in pandas object.
Date, BidOpen, BidHigh, BidLow, BidClose, Volume
13.10.2018 21:00:00, 71.45700, 72.67500, 68.45000, 69.25200, 507708
20.10.2018 21:00:00, 69.25200, 69.80600, 65.72000, 67.68500, 389174
27.10.2018 21:00:00, 67.68500, 67.92400, 62.61000, 62.85500, 454709
03.11.2018 21:00:00, 62.85500, 64.11500, 59.24400, 59.81500, 858696
10.11.2018 22:00:00, 59.81500, 61.26200, 54.73200, 56.12500, 440074
python pandas list dataframe
add a comment |
I have this raw data retreive from some source as list array enclosed by ()
[('2018-10-13T21:00:00.000000000', 71.457, 72.675, 68.45 , 69.252, 71.51 , 72.725, 68.505, 69.31 , 507708)
('2018-10-20T21:00:00.000000000', 69.252, 69.806, 65.72 , 67.685, 69.31 , 69.855, 65.77 , 67.74 , 389174)
('2018-10-27T21:00:00.000000000', 67.685, 67.924, 62.61 , 62.855, 67.74 , 67.975, 62.665, 62.905, 454709)
('2018-11-03T21:00:00.000000000', 62.855, 64.115, 59.244, 59.815, 62.905, 64.165, 59.295, 59.87 , 858696)
('2018-11-10T22:00:00.000000000', 59.815, 61.262, 54.732, 56.125, 59.87 , 61.315, 54.787, 56.175, 440074)]
I want to make this as pandas data frame and add column name ,using the for loop this is achieved with desired output ,however how to do this without for loop directly using pandas built in resources and how to store this is in pandas object.
for row in history:
print("{0:s}, {1:,.5f}, {2:,.5f}, {3:,.5f}, {4:,.5f}, {5:d}".format(
pd.to_datetime(str(row['Date'])).strftime(date_format), row['BidOpen'], row['BidHigh'],row['BidLow'], row['BidClose'], row['Volume']))
output : Here T in between the Date and Time removed and float ,decimal also take care .If not other solution how this can be stored in pandas object.
Date, BidOpen, BidHigh, BidLow, BidClose, Volume
13.10.2018 21:00:00, 71.45700, 72.67500, 68.45000, 69.25200, 507708
20.10.2018 21:00:00, 69.25200, 69.80600, 65.72000, 67.68500, 389174
27.10.2018 21:00:00, 67.68500, 67.92400, 62.61000, 62.85500, 454709
03.11.2018 21:00:00, 62.85500, 64.11500, 59.24400, 59.81500, 858696
10.11.2018 22:00:00, 59.81500, 61.26200, 54.73200, 56.12500, 440074
python pandas list dataframe
I have this raw data retreive from some source as list array enclosed by ()
[('2018-10-13T21:00:00.000000000', 71.457, 72.675, 68.45 , 69.252, 71.51 , 72.725, 68.505, 69.31 , 507708)
('2018-10-20T21:00:00.000000000', 69.252, 69.806, 65.72 , 67.685, 69.31 , 69.855, 65.77 , 67.74 , 389174)
('2018-10-27T21:00:00.000000000', 67.685, 67.924, 62.61 , 62.855, 67.74 , 67.975, 62.665, 62.905, 454709)
('2018-11-03T21:00:00.000000000', 62.855, 64.115, 59.244, 59.815, 62.905, 64.165, 59.295, 59.87 , 858696)
('2018-11-10T22:00:00.000000000', 59.815, 61.262, 54.732, 56.125, 59.87 , 61.315, 54.787, 56.175, 440074)]
I want to make this as pandas data frame and add column name ,using the for loop this is achieved with desired output ,however how to do this without for loop directly using pandas built in resources and how to store this is in pandas object.
for row in history:
print("{0:s}, {1:,.5f}, {2:,.5f}, {3:,.5f}, {4:,.5f}, {5:d}".format(
pd.to_datetime(str(row['Date'])).strftime(date_format), row['BidOpen'], row['BidHigh'],row['BidLow'], row['BidClose'], row['Volume']))
output : Here T in between the Date and Time removed and float ,decimal also take care .If not other solution how this can be stored in pandas object.
Date, BidOpen, BidHigh, BidLow, BidClose, Volume
13.10.2018 21:00:00, 71.45700, 72.67500, 68.45000, 69.25200, 507708
20.10.2018 21:00:00, 69.25200, 69.80600, 65.72000, 67.68500, 389174
27.10.2018 21:00:00, 67.68500, 67.92400, 62.61000, 62.85500, 454709
03.11.2018 21:00:00, 62.85500, 64.11500, 59.24400, 59.81500, 858696
10.11.2018 22:00:00, 59.81500, 61.26200, 54.73200, 56.12500, 440074
python pandas list dataframe
python pandas list dataframe
asked Nov 14 '18 at 12:55
Marx BabuMarx Babu
17713
17713
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This gives the correct output
df = pd.DataFrame(history, columns=['Date', 'BidOpen', 'BidHigh','BidLow', 'BidClose', 'AskOpen', 'AskHigh', 'AskLow', 'AskClose', 'Volume'])
Here the column name can be of any name.
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300751%2fpython-financial-ohlc-with-data-time-data-conversion-list-array-to-pandas-and-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This gives the correct output
df = pd.DataFrame(history, columns=['Date', 'BidOpen', 'BidHigh','BidLow', 'BidClose', 'AskOpen', 'AskHigh', 'AskLow', 'AskClose', 'Volume'])
Here the column name can be of any name.
add a comment |
This gives the correct output
df = pd.DataFrame(history, columns=['Date', 'BidOpen', 'BidHigh','BidLow', 'BidClose', 'AskOpen', 'AskHigh', 'AskLow', 'AskClose', 'Volume'])
Here the column name can be of any name.
add a comment |
This gives the correct output
df = pd.DataFrame(history, columns=['Date', 'BidOpen', 'BidHigh','BidLow', 'BidClose', 'AskOpen', 'AskHigh', 'AskLow', 'AskClose', 'Volume'])
Here the column name can be of any name.
This gives the correct output
df = pd.DataFrame(history, columns=['Date', 'BidOpen', 'BidHigh','BidLow', 'BidClose', 'AskOpen', 'AskHigh', 'AskLow', 'AskClose', 'Volume'])
Here the column name can be of any name.
answered Nov 14 '18 at 15:16
Marx BabuMarx Babu
17713
17713
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300751%2fpython-financial-ohlc-with-data-time-data-conversion-list-array-to-pandas-and-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown