Assigning a desired proportion of Total
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Please take a look at the below table (DataFrame):
Product Channel Germany France India Italy USA Canada Russia China Poland Spain Portugal
0 Rings Train 1893.0
1 Rings Airplane 4608.0 13057.0
2 Rings Truck 4528.0
3 Shoes Train 6423.0 3212.0 6669.0
4 Shoes Airplane 3803.0 3549.0 78588.0 24367.0 3169.0
5 Shoes Truck 20185.0 8624.0 9358.0 6606.0 1284.0 16698.0 11560.0 24589.0 13028.0 8819.0 18350.0
6 Watch Train 2035.0 1018.0 2113.0
7 Watch Airplane 653.0 586.0 14997.0 4464.0 688.0
8 Watch Truck 2574.0 1100.0 1193.0 842.0 164.0 2129.0 1474.0 3135.0 1661.0 1124.0 2340.0
PROPORTION 0.09256 0.04204 0.05837 0.03434 0.33865 0.05582 0.03864 0.08220 0.04355 0.14100 0.07278
The proportion indicates the share of each country of the Total.
What would be the right approach to modify the individual numbers, so that e.g. Germany and France make up exactly 10%?
I can only change the rows which are not empty and the total of each row has to remain the same after this is done.
The change done to the other countries should ideally be proportional to their size, e.g. USA should give/take most of the numbers as they make up 1/3 of the whole.
Is this a form of linear programming or are other methods used for a task like this? I'd appreciate some thoughts what field/library I should look into to make this work, if the specific solution to this task itself is too complex.
python pandas optimization
add a comment |
Please take a look at the below table (DataFrame):
Product Channel Germany France India Italy USA Canada Russia China Poland Spain Portugal
0 Rings Train 1893.0
1 Rings Airplane 4608.0 13057.0
2 Rings Truck 4528.0
3 Shoes Train 6423.0 3212.0 6669.0
4 Shoes Airplane 3803.0 3549.0 78588.0 24367.0 3169.0
5 Shoes Truck 20185.0 8624.0 9358.0 6606.0 1284.0 16698.0 11560.0 24589.0 13028.0 8819.0 18350.0
6 Watch Train 2035.0 1018.0 2113.0
7 Watch Airplane 653.0 586.0 14997.0 4464.0 688.0
8 Watch Truck 2574.0 1100.0 1193.0 842.0 164.0 2129.0 1474.0 3135.0 1661.0 1124.0 2340.0
PROPORTION 0.09256 0.04204 0.05837 0.03434 0.33865 0.05582 0.03864 0.08220 0.04355 0.14100 0.07278
The proportion indicates the share of each country of the Total.
What would be the right approach to modify the individual numbers, so that e.g. Germany and France make up exactly 10%?
I can only change the rows which are not empty and the total of each row has to remain the same after this is done.
The change done to the other countries should ideally be proportional to their size, e.g. USA should give/take most of the numbers as they make up 1/3 of the whole.
Is this a form of linear programming or are other methods used for a task like this? I'd appreciate some thoughts what field/library I should look into to make this work, if the specific solution to this task itself is too complex.
python pandas optimization
add a comment |
Please take a look at the below table (DataFrame):
Product Channel Germany France India Italy USA Canada Russia China Poland Spain Portugal
0 Rings Train 1893.0
1 Rings Airplane 4608.0 13057.0
2 Rings Truck 4528.0
3 Shoes Train 6423.0 3212.0 6669.0
4 Shoes Airplane 3803.0 3549.0 78588.0 24367.0 3169.0
5 Shoes Truck 20185.0 8624.0 9358.0 6606.0 1284.0 16698.0 11560.0 24589.0 13028.0 8819.0 18350.0
6 Watch Train 2035.0 1018.0 2113.0
7 Watch Airplane 653.0 586.0 14997.0 4464.0 688.0
8 Watch Truck 2574.0 1100.0 1193.0 842.0 164.0 2129.0 1474.0 3135.0 1661.0 1124.0 2340.0
PROPORTION 0.09256 0.04204 0.05837 0.03434 0.33865 0.05582 0.03864 0.08220 0.04355 0.14100 0.07278
The proportion indicates the share of each country of the Total.
What would be the right approach to modify the individual numbers, so that e.g. Germany and France make up exactly 10%?
I can only change the rows which are not empty and the total of each row has to remain the same after this is done.
The change done to the other countries should ideally be proportional to their size, e.g. USA should give/take most of the numbers as they make up 1/3 of the whole.
Is this a form of linear programming or are other methods used for a task like this? I'd appreciate some thoughts what field/library I should look into to make this work, if the specific solution to this task itself is too complex.
python pandas optimization
Please take a look at the below table (DataFrame):
Product Channel Germany France India Italy USA Canada Russia China Poland Spain Portugal
0 Rings Train 1893.0
1 Rings Airplane 4608.0 13057.0
2 Rings Truck 4528.0
3 Shoes Train 6423.0 3212.0 6669.0
4 Shoes Airplane 3803.0 3549.0 78588.0 24367.0 3169.0
5 Shoes Truck 20185.0 8624.0 9358.0 6606.0 1284.0 16698.0 11560.0 24589.0 13028.0 8819.0 18350.0
6 Watch Train 2035.0 1018.0 2113.0
7 Watch Airplane 653.0 586.0 14997.0 4464.0 688.0
8 Watch Truck 2574.0 1100.0 1193.0 842.0 164.0 2129.0 1474.0 3135.0 1661.0 1124.0 2340.0
PROPORTION 0.09256 0.04204 0.05837 0.03434 0.33865 0.05582 0.03864 0.08220 0.04355 0.14100 0.07278
The proportion indicates the share of each country of the Total.
What would be the right approach to modify the individual numbers, so that e.g. Germany and France make up exactly 10%?
I can only change the rows which are not empty and the total of each row has to remain the same after this is done.
The change done to the other countries should ideally be proportional to their size, e.g. USA should give/take most of the numbers as they make up 1/3 of the whole.
Is this a form of linear programming or are other methods used for a task like this? I'd appreciate some thoughts what field/library I should look into to make this work, if the specific solution to this task itself is too complex.
python pandas optimization
python pandas optimization
edited Nov 24 '18 at 12:25
Bishonen_PL
asked Nov 24 '18 at 12:07
Bishonen_PLBishonen_PL
13910
13910
add a comment |
add a comment |
0
active
oldest
votes
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%2f53457982%2fassigning-a-desired-proportion-of-total%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53457982%2fassigning-a-desired-proportion-of-total%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