title
How do I select multiple rows and columns from a pandas DataFrame?

description
Have you ever been confused about the "right" way to select rows and columns from a DataFrame? pandas gives you an incredible number of options for doing so, but in this video, I'll outline the current best practices for row and column selection using the loc, iloc, and ix methods. SUBSCRIBE to learn data science with Python: https://www.youtube.com/dataschool?sub_confirmation=1 JOIN the "Data School Insiders" community and receive exclusive rewards: https://www.patreon.com/dataschool == RESOURCES == GitHub repository for the series: https://github.com/justmarkham/pandas-videos "loc" documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html "iloc" documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iloc.html "ix" documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html Summary of the pandas API for selection: https://github.com/pydata/pandas/issues/9595 == LET'S CONNECT! == Newsletter: https://www.dataschool.io/subscribe/ Twitter: https://twitter.com/justmarkham Facebook: https://www.facebook.com/DataScienceSchool/ LinkedIn: https://www.linkedin.com/in/justmarkham/

detail
{'title': 'How do I select multiple rows and columns from a pandas DataFrame?', 'heatmap': [{'end': 513.196, 'start': 477.014, 'weight': 1}, {'end': 644.119, 'start': 614.237, 'weight': 0.757}], 'summary': "Covers pandas dataframe selection, discussing differences between loc, iloc, and ix methods, highlighting loc's flexibility in selecting specific rows and columns, demonstrating the explicitness of loc method in comparison, explaining differences between loc and iloc, recommending explicit use of .loc for selecting multiple columns and rows, and introducing pandas ix selection logic for data selection.", 'chapters': [{'end': 404.473, 'segs': [{'end': 33.138, 'src': 'embed', 'start': 1.442, 'weight': 0, 'content': [{'end': 7.684, 'text': 'Hello, and welcome back to my Q&A video series about the Pandas library in Python.', 'start': 1.442, 'duration': 6.242}, {'end': 19.609, 'text': 'And the question for today comes from a YouTube commenter who asks can you make a video dedicated in pointing out the differences between loc,', 'start': 8.465, 'duration': 11.144}, {'end': 21.11, 'text': 'iloc and ix?', 'start': 19.609, 'duration': 1.501}, {'end': 22.951, 'text': 'Okay, great question.', 'start': 21.75, 'duration': 1.201}, {'end': 33.138, 'text': "So loc, iloc and ix are different data frame methods for selecting rows and columns and they're very flexible and powerful,", 'start': 23.031, 'duration': 10.107}], 'summary': 'Q&a video on pandas library discusses differences between loc, iloc, and ix for selecting rows and columns.', 'duration': 31.696, 'max_score': 1.442, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs1442.jpg'}, {'end': 152.966, 'src': 'embed', 'start': 66.328, 'weight': 1, 'content': [{'end': 73.293, 'text': 'So, if you wanted to look at the first few rows, your natural inclination might be to use the head method.', 'start': 66.328, 'duration': 6.965}, {'end': 80.958, 'text': "So, if we want to see the first three rows, ufo.head and that'll show us those first three rows.", 'start': 73.813, 'duration': 7.145}, {'end': 88.443, 'text': "But, there are lots of other ways to do this, and loc is one of them, and it's a lot more powerful and flexible.", 'start': 82.139, 'duration': 6.304}, {'end': 90.064, 'text': "So, let's try it out.", 'start': 88.844, 'duration': 1.22}, {'end': 98.809, 'text': "So, loc is, because it's a data frame method, you say ufo.loc.", 'start': 91.085, 'duration': 7.724}, {'end': 105.273, 'text': 'And loc is for filtering rows and selecting columns by label.', 'start': 99.95, 'duration': 5.323}, {'end': 109.235, 'text': 'And by label, I mean, for rows, I mean the index.', 'start': 105.853, 'duration': 3.382}, {'end': 111.857, 'text': 'For columns, I mean the column names.', 'start': 109.636, 'duration': 2.221}, {'end': 113.258, 'text': "Okay, that's the label.", 'start': 111.877, 'duration': 1.381}, {'end': 117.12, 'text': 'So loc is for selecting things by label.', 'start': 113.738, 'duration': 3.382}, {'end': 133.029, 'text': "So, you don't use parentheses, you use a bracket, and the format of the loc command is what rows do I want, comma, what columns do I want.", 'start': 118.476, 'duration': 14.553}, {'end': 142.017, 'text': 'So, if I want row zero and all columns, I say this.', 'start': 134.731, 'duration': 7.286}, {'end': 147.001, 'text': 'ufo dot, loc, bracket zero, comma colon.', 'start': 143.098, 'duration': 3.903}, {'end': 150.864, 'text': 'so the colon means all columns.', 'start': 147.001, 'duration': 3.863}, {'end': 152.966, 'text': 'so row zero all columns.', 'start': 150.864, 'duration': 2.102}], 'summary': 'Using loc method in ufo dataframe for powerful and flexible filtering and selection by label.', 'duration': 86.638, 'max_score': 66.328, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs66328.jpg'}, {'end': 228.829, 'src': 'embed', 'start': 191.603, 'weight': 3, 'content': [{'end': 194.902, 'text': 'So which rows do I want? 0, 1, 2.', 'start': 191.603, 'duration': 3.299}, {'end': 197.064, 'text': 'Which columns do I want? All of them.', 'start': 194.904, 'duration': 2.16}, {'end': 200.155, 'text': 'And here we go.', 'start': 199.615, 'duration': 0.54}, {'end': 210.426, 'text': "Now, there's actually a more efficient way because we want this continuous block of rows.", 'start': 201.597, 'duration': 8.829}, {'end': 215.992, 'text': 'I could say you can actually just use.', 'start': 212.548, 'duration': 3.444}, {'end': 221.941, 'text': 'ufo.loc, colon two, comma, colon.', 'start': 218.177, 'duration': 3.764}, {'end': 226.347, 'text': 'So which rows do I want? Zero through two.', 'start': 222.222, 'duration': 4.125}, {'end': 228.829, 'text': 'And I want all columns.', 'start': 227.528, 'duration': 1.301}], 'summary': 'Selecting rows 0-2 and all columns using ufo.loc for efficiency.', 'duration': 37.226, 'max_score': 191.603, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs191603.jpg'}, {'end': 298.12, 'src': 'embed', 'start': 264.255, 'weight': 4, 'content': [{'end': 273.781, 'text': "So that's really important to remember that loc is inclusive on both sides when you use this notation.", 'start': 264.255, 'duration': 9.526}, {'end': 282.587, 'text': "Now, I will mention, I'm not gonna recommend you do this, but I will mention that sometimes you'll see code like this.", 'start': 275.642, 'duration': 6.945}, {'end': 289.615, 'text': "And you'll think, wait a minute, I thought it was rows, comma, columns.", 'start': 284.352, 'duration': 5.263}, {'end': 298.12, 'text': "And that's true, but it turns out if you leave off the comma, colon, pandas just assumes it.", 'start': 290.576, 'duration': 7.544}], 'summary': 'Pandas assumes inclusive loc notation; leaving off comma implies rows, columns.', 'duration': 33.865, 'max_score': 264.255, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs264255.jpg'}], 'start': 1.442, 'title': 'Pandas dataframe selection', 'summary': 'Discusses the differences between loc, iloc, and ix methods in the pandas library, emphasizing the flexibility and power of these methods. it also explains how to use the loc command in pandas to select specific rows and columns from a dataframe, including using brackets and the colon notation.', 'chapters': [{'end': 117.12, 'start': 1.442, 'title': 'Pandas: loc, iloc, ix methods', 'summary': 'Discusses the differences between loc, iloc, and ix methods in the pandas library for selecting rows and columns, emphasizing the flexibility and power of these methods using an example dataset of ufo reported sightings.', 'duration': 115.678, 'highlights': ['The loc method in Pandas is a more powerful and flexible way to select rows and columns by label, using the index for rows and column names for columns.', 'The chapter provides an example of using the loc method to filter rows and select columns in a dataset of UFO reported sightings, showcasing its flexibility and power.', 'Understanding the differences between loc, iloc, and ix methods is essential for effectively selecting and manipulating data in Pandas.']}, {'end': 404.473, 'start': 118.476, 'title': 'Pandas dataframe selection', 'summary': 'Explains how to use the loc command in pandas to select specific rows and columns from a dataframe, including using brackets and the colon notation, and provides a caution about leaving off the comma in code structure.', 'duration': 285.997, 'highlights': ['The loc command in Pandas is used to select specific rows and columns from a DataFrame. ', 'Using the format ufo.loc[0, :] returns the first row of the DataFrame with all columns. ', 'Using the format ufo.loc[[0, 1, 2], :] returns rows 0, 1, and 2 with all columns. ', 'The format ufo.loc[:2, :] efficiently returns rows 0 through 2 with all columns. ', 'The loc notation is inclusive on both sides, unlike the behavior of the range function in Python. ', 'Leaving off the comma in the loc command still returns the same result, although it is recommended to be explicit about row and column selection for readability and clarity. ', "Column selection using the loc command involves specifying the desired column, such as 'city', and can also involve selecting multiple columns or a range of columns. ", 'Combining row and column selection with the loc command provides flexibility in selecting specific data from the DataFrame. ']}], 'duration': 403.031, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs1442.jpg', 'highlights': ['Understanding the differences between loc, iloc, and ix methods is essential for effectively selecting and manipulating data in Pandas.', 'The loc method in Pandas is a more powerful and flexible way to select rows and columns by label, using the index for rows and column names for columns.', 'The chapter provides an example of using the loc method to filter rows and select columns in a dataset of UFO reported sightings, showcasing its flexibility and power.', 'Using the format ufo.loc[:2, :] efficiently returns rows 0 through 2 with all columns.', 'The loc notation is inclusive on both sides, unlike the behavior of the range function in Python.', "Column selection using the loc command involves specifying the desired column, such as 'city', and can also involve selecting multiple columns or a range of columns."]}, {'end': 561.837, 'segs': [{'end': 466.473, 'src': 'embed', 'start': 405.213, 'weight': 0, 'content': [{'end': 408.815, 'text': "And I'd ask you real quick what's another way?", 'start': 405.213, 'duration': 3.602}, {'end': 412.877, 'text': 'we could do this, this exact same thing without using the loc method?', 'start': 408.815, 'duration': 4.062}, {'end': 414.671, 'text': 'Think about that for a second.', 'start': 413.43, 'duration': 1.241}, {'end': 415.831, 'text': 'pause the video if you need.', 'start': 414.671, 'duration': 1.16}, {'end': 424.596, 'text': 'But if you remember back to previous videos, you could accomplish the same thing with ufo.head3 and then .', 'start': 416.892, 'duration': 7.704}, {'end': 437.441, 'text': 'drop time axis equals one, okay? So, same thing, totally different kind of workflow.', 'start': 424.596, 'duration': 12.845}, {'end': 444.724, 'text': 'The point here is there are always lots of ways to do the same thing in pandas,', 'start': 438.902, 'duration': 5.822}, {'end': 450.006, 'text': 'and it comes down to what methods you feel most comfortable with and you know the best.', 'start': 444.724, 'duration': 5.282}, {'end': 452.587, 'text': "I'll just say that .", 'start': 450.506, 'duration': 2.081}, {'end': 454.988, 'text': 'loc is super powerful and flexible.', 'start': 452.587, 'duration': 2.401}, {'end': 466.473, 'text': "There is another use for loc that's useful to know, and it's using loc with Boolean conditions.", 'start': 458.891, 'duration': 7.582}], 'summary': 'Multiple methods to achieve the same task in pandas, with loc being a powerful and flexible option.', 'duration': 61.26, 'max_score': 405.213, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs405213.jpg'}, {'end': 513.196, 'src': 'heatmap', 'start': 477.014, 'weight': 1, 'content': [{'end': 484.816, 'text': 'you would do this ufo bracket ufo.city equals equals Oakland.', 'start': 477.014, 'duration': 7.802}, {'end': 491.26, 'text': 'and you probably remember this from a previous video where city is Oakland okay?', 'start': 485.436, 'duration': 5.824}, {'end': 498.005, 'text': "However, you can do the same thing with loc, and it's even a bit more flexible.", 'start': 492.481, 'duration': 5.524}, {'end': 513.196, 'text': 'So I could say ufo.loc and then what do we need to tell it? What rows do I want? Well, the rows in which ufo.city equals Oakland.', 'start': 498.746, 'duration': 14.45}], 'summary': 'Using the ufo.loc function to filter rows where ufo.city equals oakland.', 'duration': 36.182, 'max_score': 477.014, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs477014.jpg'}, {'end': 561.837, 'src': 'embed', 'start': 531.993, 'weight': 2, 'content': [{'end': 539.878, 'text': "And in fact, it's again more flexible because you could specify, oh, I just want the state column.", 'start': 531.993, 'duration': 7.885}, {'end': 541.999, 'text': 'And you just get the state.', 'start': 540.878, 'duration': 1.121}, {'end': 545.416, 'text': 'Now, you might be thinking, well, wait a minute.', 'start': 543.055, 'duration': 2.361}, {'end': 546.437, 'text': "I don't need .", 'start': 545.677, 'duration': 0.76}, {'end': 547.498, 'text': 'loc to do that.', 'start': 546.437, 'duration': 1.061}, {'end': 550.339, 'text': 'I can just add on .', 'start': 548.418, 'duration': 1.921}, {'end': 551.88, 'text': 'state at the end here.', 'start': 550.339, 'duration': 1.541}, {'end': 553.982, 'text': "And you're right.", 'start': 553.261, 'duration': 0.721}, {'end': 561.837, 'text': "However, there's actually a subtle difference in how this code and this code executes.", 'start': 554.932, 'duration': 6.905}], 'summary': 'Pandas offers flexibility in specifying columns, demonstrating a subtle difference in code execution.', 'duration': 29.844, 'max_score': 531.993, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs531993.jpg'}], 'start': 405.213, 'title': 'Pandas loc method', 'summary': 'Discusses the flexibility of the loc method in pandas, highlighting its various ways of accomplishing the same task and its usefulness with boolean conditions, demonstrating its flexibility and explicitness compared to other methods.', 'chapters': [{'end': 561.837, 'start': 405.213, 'title': 'Pandas loc method and its flexibility', 'summary': 'Discusses the flexibility of the loc method in pandas, highlighting its various ways of accomplishing the same task and its usefulness with boolean conditions, demonstrating its flexibility and explicitness compared to other methods.', 'duration': 156.624, 'highlights': ['The loc method in pandas provides various ways to accomplish the same task, such as using ufo.head3 and then . drop time axis equals one, offering a different workflow.', 'Using loc with Boolean conditions allows for more flexibility and explicitness in selecting rows and columns, enhancing its usefulness compared to other methods.', 'The loc method is more flexible as it allows specifying particular columns for selection, offering a subtle difference in execution compared to other methods.']}], 'duration': 156.624, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs405213.jpg', 'highlights': ['Using loc with Boolean conditions allows for more flexibility and explicitness in selecting rows and columns, enhancing its usefulness compared to other methods.', 'The loc method in pandas provides various ways to accomplish the same task, such as using ufo.head3 and then . drop time axis equals one, offering a different workflow.', 'The loc method is more flexible as it allows specifying particular columns for selection, offering a subtle difference in execution compared to other methods.']}, {'end': 765.631, 'segs': [{'end': 613.577, 'src': 'embed', 'start': 583.674, 'weight': 0, 'content': [{'end': 591.338, 'text': 'Whereas, this takes two operations and because of that, this is safer for your code executing in the way you want.', 'start': 583.674, 'duration': 7.664}, {'end': 596.721, 'text': "As I said, I'll talk about that more in a future video.", 'start': 592.138, 'duration': 4.583}, {'end': 598.221, 'text': "That's it for loc.", 'start': 597.041, 'duration': 1.18}, {'end': 600.803, 'text': "Let's talk a little bit about iloc.", 'start': 598.962, 'duration': 1.841}, {'end': 609.792, 'text': 'iloc is for filtering rows and selecting columns by integer position.', 'start': 604.486, 'duration': 5.306}, {'end': 613.577, 'text': "That's what the I stands for is integer position.", 'start': 610.233, 'duration': 3.344}], 'summary': 'Iloc is safer, requiring two operations, for row and column selection by integer position.', 'duration': 29.903, 'max_score': 583.674, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs583674.jpg'}, {'end': 644.119, 'src': 'heatmap', 'start': 614.237, 'weight': 0.757, 'content': [{'end': 619.423, 'text': "So I can say ufo.iloc, and it's just like before.", 'start': 614.237, 'duration': 5.186}, {'end': 620.785, 'text': 'what rows do I want??', 'start': 619.423, 'duration': 1.362}, {'end': 622.327, 'text': 'What columns do I want??', 'start': 620.965, 'duration': 1.362}, {'end': 636.092, 'text': "So if I said I want all rows and I want columns in position zero and three, I will get the city and state columns because that's position zero.", 'start': 622.867, 'duration': 13.225}, {'end': 638.815, 'text': "that's position three, the data frame.", 'start': 636.092, 'duration': 2.723}, {'end': 644.119, 'text': 'okay?. As before, I can also use a range.', 'start': 638.815, 'duration': 5.304}], 'summary': 'Using iloc to select specific rows and columns from a data frame.', 'duration': 29.882, 'max_score': 614.237, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs614237.jpg'}, {'end': 765.631, 'src': 'embed', 'start': 736.36, 'weight': 1, 'content': [{'end': 739.822, 'text': "All right, so that's a big difference between loc and iloc.", 'start': 736.36, 'duration': 3.462}, {'end': 746.306, 'text': 'So, loc for labels, iloc for integer position, loc.', 'start': 740.422, 'duration': 5.884}, {'end': 749.868, 'text': "when you do ranges, it's inclusive on both sides.", 'start': 746.306, 'duration': 3.562}, {'end': 756.712, 'text': 'iloc inclusive on the start and exclusive of the stop, okay?', 'start': 749.868, 'duration': 6.844}, {'end': 765.631, 'text': "All right, I'm going to show you a couple shortcuts that I don't recommend using, but I want you to be aware of them,", 'start': 758.163, 'duration': 7.468}], 'summary': 'Difference between loc and iloc for labels and integer position, with inclusive ranges.', 'duration': 29.271, 'max_score': 736.36, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs736360.jpg'}], 'start': 562.518, 'title': 'Pandas loc vs iloc', 'summary': 'Explains the differences between loc and iloc in pandas for filtering rows and selecting columns, highlighting the inclusive/exclusive range behavior and the advantages of using iloc for certain operations.', 'chapters': [{'end': 765.631, 'start': 562.518, 'title': 'Pandas loc vs iloc', 'summary': 'Explains the differences between loc and iloc in pandas for filtering rows and selecting columns, highlighting the inclusive/exclusive range behavior and the advantages of using iloc for certain operations.', 'duration': 203.113, 'highlights': ['iloc is for filtering rows and selecting columns by integer position, with exclusive behavior for the stop index and inclusive behavior for the start index.', 'Using iloc for Boolean selection of rows and column selection accomplishes it in one internal operation, making it safer for code execution.', 'Loc is inclusive on both sides when doing ranges, whereas iloc is inclusive on the start and exclusive of the stop, a behavior similar to the range function.']}], 'duration': 203.113, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs562518.jpg', 'highlights': ['Using iloc for Boolean selection of rows and column selection accomplishes it in one internal operation, making it safer for code execution.', 'Loc is inclusive on both sides when doing ranges, whereas iloc is inclusive on the start and exclusive of the stop, a behavior similar to the range function.', 'iloc is for filtering rows and selecting columns by integer position, with exclusive behavior for the stop index and inclusive behavior for the start index.']}, {'end': 872.307, 'segs': [{'end': 849.851, 'src': 'embed', 'start': 799.374, 'weight': 0, 'content': [{'end': 804.958, 'text': 'If you pass a list of strings to the outer brackets, it knows you want to select columns.', 'start': 799.374, 'duration': 5.584}, {'end': 807.82, 'text': "But that's a lot of logic to remember.", 'start': 805.819, 'duration': 2.001}, {'end': 811.543, 'text': 'What I recommend instead is just to use .', 'start': 808.281, 'duration': 3.262}, {'end': 814.645, 'text': 'loc and say, Which rows? All of them.', 'start': 811.543, 'duration': 3.102}, {'end': 817.366, 'text': 'Which columns do I want? City and state.', 'start': 815.025, 'duration': 2.341}, {'end': 823.929, 'text': "So this is what I recommend because it's very explicit about what you want.", 'start': 818.607, 'duration': 5.322}, {'end': 834.724, 'text': "Similarly, you're often gonna see this, which I find confusing, which is UFO, bracket, zero, colon, two.", 'start': 825.561, 'duration': 9.163}, {'end': 835.744, 'text': "There's no .", 'start': 834.964, 'duration': 0.78}, {'end': 838.845, 'text': "loc, there's no iloc, it's just zero, colon, two.", 'start': 835.744, 'duration': 3.101}, {'end': 841.866, 'text': 'And you might think is that referring to rows?', 'start': 839.305, 'duration': 2.561}, {'end': 843.547, 'text': 'Is that referring to columns??', 'start': 842.106, 'duration': 1.441}, {'end': 848.27, 'text': 'those labels are those integer positions?', 'start': 844.867, 'duration': 3.403}, {'end': 849.851, 'text': "i don't know.", 'start': 848.27, 'duration': 1.581}], 'summary': 'Using .loc for explicit column selection is recommended for better clarity and understanding.', 'duration': 50.477, 'max_score': 799.374, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs799374.jpg'}], 'start': 765.631, 'title': 'Selecting columns and rows in pandas', 'summary': 'Discusses the confusion around selecting multiple columns and rows in pandas, recommending the explicit use of .loc for clarity and ease of understanding.', 'chapters': [{'end': 872.307, 'start': 765.631, 'title': 'Selecting columns and rows in pandas', 'summary': 'Discusses the confusion around selecting multiple columns and rows in pandas, recommending the explicit use of .loc for clarity and ease of understanding.', 'duration': 106.676, 'highlights': ['The use of UFO bracket bracket city comma state to select two columns is common, but using .loc to specify the columns explicitly is recommended for clarity and ease of understanding.', 'The confusion around using UFO bracket zero colon two to select rows is addressed, with the recommendation to use .iloc for clarity and understanding.']}], 'duration': 106.676, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs765631.jpg', 'highlights': ['Using .loc to specify columns explicitly is recommended for clarity and understanding', 'Addressing confusion around using UFO bracket zero colon two to select rows, recommending .iloc for clarity']}, {'end': 1303.895, 'segs': [{'end': 908.092, 'src': 'embed', 'start': 873.668, 'weight': 0, 'content': [{'end': 881.972, 'text': 'This is much better because you know, okay, position zero through two, inclusive, exclusive, and then all columns.', 'start': 873.668, 'duration': 8.304}, {'end': 887.515, 'text': "Now let's move to IX.", 'start': 884.954, 'duration': 2.561}, {'end': 894.299, 'text': 'And what is IX? It allows you to mix labels and integers.', 'start': 888.436, 'duration': 5.863}, {'end': 897.889, 'text': 'when doing selection.', 'start': 896.568, 'duration': 1.321}, {'end': 901.75, 'text': "So it's kind of like a blend between loc and iloc, okay?", 'start': 898.169, 'duration': 3.581}, {'end': 907.111, 'text': "So to demonstrate this one, I'm gonna pull in another data set, the drinks data set.", 'start': 902.21, 'duration': 4.901}, {'end': 908.092, 'text': "we've seen many times.", 'start': 907.111, 'duration': 0.981}], 'summary': 'Ix allows mixing labels and integers for selection, like a blend between loc and iloc.', 'duration': 34.424, 'max_score': 873.668, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs873668.jpg'}, {'end': 1183.404, 'src': 'embed', 'start': 1151.437, 'weight': 1, 'content': [{'end': 1159.506, 'text': "but I generally don't recommend it because you have to keep track of the intricate logic of ix.", 'start': 1151.437, 'duration': 8.069}, {'end': 1163.65, 'text': 'ix was invented in pandas before loc and iloc.', 'start': 1160.667, 'duration': 2.983}, {'end': 1170.597, 'text': "That's why lots of people got used to using ix, but I only recommend using ix if you have to.", 'start': 1164.031, 'duration': 6.566}, {'end': 1183.404, 'text': 'If loc is not meeting your needs and iloc is not meeting your needs and you need to mix positions and labels in the same call, then use ix.', 'start': 1171.518, 'duration': 11.886}], 'summary': 'Prefer using loc and iloc over ix, unless needing to mix positions and labels.', 'duration': 31.967, 'max_score': 1151.437, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs1151437.jpg'}], 'start': 873.668, 'title': 'Pandas ix selection logic', 'summary': 'Introduces the pandas ix selection logic, allowing the mixing of labels and integers for data selection, and provides insights into its usage, advantages, and limitations.', 'chapters': [{'end': 1303.895, 'start': 873.668, 'title': 'Pandas ix selection logic', 'summary': 'Introduces the pandas ix selection logic, allowing the mixing of labels and integers for data selection, and provides insights into its usage, advantages, and limitations, including the announcement of changes in video release schedule and promotion of the data school newsletter.', 'duration': 430.227, 'highlights': ['Pandas IX selection logic allows mixing labels and integers for data selection, providing flexibility in selecting specific cells or ranges within a dataset.', 'The usage of IX is advised only if loc and iloc are insufficient, as it requires understanding its intricate logic and can be confusing, especially with non-sequential integer indexes.', 'Announcement: Upcoming changes in video release schedule, with videos only being released on Tuesdays for June and July due to upcoming travel and marriage.', 'Promotion of the Data School newsletter, encouraging viewers to join the newsletter for access to relevant documentation, helpful resources, and great content on data science.']}], 'duration': 430.227, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/xvpNA7bC8cs/pics/xvpNA7bC8cs873668.jpg', 'highlights': ['Pandas IX selection logic allows mixing labels and integers for data selection, providing flexibility in selecting specific cells or ranges within a dataset.', 'The usage of IX is advised only if loc and iloc are insufficient, as it requires understanding its intricate logic and can be confusing, especially with non-sequential integer indexes.']}], 'highlights': ['The loc method in Pandas is a more powerful and flexible way to select rows and columns by label, using the index for rows and column names for columns.', 'Using loc with Boolean conditions allows for more flexibility and explicitness in selecting rows and columns, enhancing its usefulness compared to other methods.', 'Using iloc for Boolean selection of rows and column selection accomplishes it in one internal operation, making it safer for code execution.', 'Using .loc to specify columns explicitly is recommended for clarity and understanding', 'Pandas IX selection logic allows mixing labels and integers for data selection, providing flexibility in selecting specific cells or ranges within a dataset.']}