Strange output with Python Lists
up vote
2
down vote
favorite
I have a dataframe: Outlet_results
it goes something like this
index Calendar year/Week Material Sellthru Qty
0 37.2013 ABC 2
1 38.2913 ABC 7
2 37.2913 BCG 22
3 39.2013 XYZ 5
Now, I wanted a separate list for the Materials and week for further coding.
I used this code for the material list
mat_outlet = list(set(outlet_result['Material']))
It works perfectly and gives me 3 values (ABC, BCG, XYZ)
However, the week list shows a faulty output even though the code is same.
week_outlet_list = list(set(outlet_result['Calendar Year/Week']))
I am getting a list with 4 values
['38.2013', '37.2013', 'Calendar Year/Week', '39.2013']
Why is the string (header) included in the list? Please help me understand this concept.
I am using Python 2.7.... has it got something to do with it?
python-2.7 list
add a comment |
up vote
2
down vote
favorite
I have a dataframe: Outlet_results
it goes something like this
index Calendar year/Week Material Sellthru Qty
0 37.2013 ABC 2
1 38.2913 ABC 7
2 37.2913 BCG 22
3 39.2013 XYZ 5
Now, I wanted a separate list for the Materials and week for further coding.
I used this code for the material list
mat_outlet = list(set(outlet_result['Material']))
It works perfectly and gives me 3 values (ABC, BCG, XYZ)
However, the week list shows a faulty output even though the code is same.
week_outlet_list = list(set(outlet_result['Calendar Year/Week']))
I am getting a list with 4 values
['38.2013', '37.2013', 'Calendar Year/Week', '39.2013']
Why is the string (header) included in the list? Please help me understand this concept.
I am using Python 2.7.... has it got something to do with it?
python-2.7 list
does thisCalendar Year/WeekorCalendar year/Weekaffect the results ? not the same; notice year and Year
– Redanium
Nov 10 at 13:36
1
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a dataframe: Outlet_results
it goes something like this
index Calendar year/Week Material Sellthru Qty
0 37.2013 ABC 2
1 38.2913 ABC 7
2 37.2913 BCG 22
3 39.2013 XYZ 5
Now, I wanted a separate list for the Materials and week for further coding.
I used this code for the material list
mat_outlet = list(set(outlet_result['Material']))
It works perfectly and gives me 3 values (ABC, BCG, XYZ)
However, the week list shows a faulty output even though the code is same.
week_outlet_list = list(set(outlet_result['Calendar Year/Week']))
I am getting a list with 4 values
['38.2013', '37.2013', 'Calendar Year/Week', '39.2013']
Why is the string (header) included in the list? Please help me understand this concept.
I am using Python 2.7.... has it got something to do with it?
python-2.7 list
I have a dataframe: Outlet_results
it goes something like this
index Calendar year/Week Material Sellthru Qty
0 37.2013 ABC 2
1 38.2913 ABC 7
2 37.2913 BCG 22
3 39.2013 XYZ 5
Now, I wanted a separate list for the Materials and week for further coding.
I used this code for the material list
mat_outlet = list(set(outlet_result['Material']))
It works perfectly and gives me 3 values (ABC, BCG, XYZ)
However, the week list shows a faulty output even though the code is same.
week_outlet_list = list(set(outlet_result['Calendar Year/Week']))
I am getting a list with 4 values
['38.2013', '37.2013', 'Calendar Year/Week', '39.2013']
Why is the string (header) included in the list? Please help me understand this concept.
I am using Python 2.7.... has it got something to do with it?
python-2.7 list
python-2.7 list
asked Nov 10 at 12:02
rahul
484
484
does thisCalendar Year/WeekorCalendar year/Weekaffect the results ? not the same; notice year and Year
– Redanium
Nov 10 at 13:36
1
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50
add a comment |
does thisCalendar Year/WeekorCalendar year/Weekaffect the results ? not the same; notice year and Year
– Redanium
Nov 10 at 13:36
1
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50
does this
Calendar Year/Week or Calendar year/Week affect the results ? not the same; notice year and Year– Redanium
Nov 10 at 13:36
does this
Calendar Year/Week or Calendar year/Week affect the results ? not the same; notice year and Year– Redanium
Nov 10 at 13:36
1
1
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50
add a comment |
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53238739%2fstrange-output-with-python-lists%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
does this
Calendar Year/WeekorCalendar year/Weekaffect the results ? not the same; notice year and Year– Redanium
Nov 10 at 13:36
1
No, I just made a mistake while writing the question. But it turns out there's a problem with the excel file. The values for week was coming as Strings. I fixed it and now it works!
– rahul
Nov 10 at 14:50