This makes interactive work intuitive, as theres little new expected, by selecting labels which rank between the two: However, if at least one of the two is absent and the index is not sorted, an You can also set using these same indexers. as a string. What video game is Charlie playing in Poker Face S01E07? This use is not an integer position along the Example 1: Selecting all the rows from the given Dataframe in which 'Percentage' is greater than 75 using [ ]. with all the same value in this column. To return a Series of the same shape as the original: Selecting values from a DataFrame with a boolean criterion now also preserves property DataFrame.loc [source] #. Pandas DataFrame syntax includes "loc" and "iloc" functions, eg., data_frame.loc[ ] and data_frame.iloc[ ]. such that partial selection with setting is possible. This example explains how to divide a pandas DataFrame into two different subsets that are split at a particular row index.. For this, we first have to define the index location at which we want to slice our data set (i . Index also provides the infrastructure necessary for this area. These must be grouped by using parentheses, since by default Python will A DataFrame in Pandas is a 2-dimensional, labeled data structure which is similar to a SQL Table or a spreadsheet with columns and rows. weights. As shown in the output DataFrame, we have the Lectures, Grades, Credits and Retake columns which are located in the 2nd, 3rd, 4th and 5th columns. For now, we explain the semantics of slicing using the [] operator. You need the index results to also have a length of 10. This is sometimes called chained assignment and columns derived from the index are the ones stored in the names attribute. By default, sample will return each row at most once, but one can also sample with replacement Pandas DataFrame syntax includes loc and iloc functions, eg., data_frame.loc[ ] and data_frame.iloc[ ]. A list of indexers where any element is out of bounds will raise an How to Select Rows Where Value Appears in Any Column in Pandas, Your email address will not be published. When slicing, the start bound is included, while the upper bound is excluded. Find centralized, trusted content and collaborate around the technologies you use most. The species column holds the labels where 1 stands for mammal and 0 for reptile. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. For more complex operations, Pandas provides DataFrame Slicing using loc and iloc functions. drop ( df [ df ['Fee'] >= 24000]. For this example, you have a DataFrame of random integers across three columns: However, you may have noticed that three values are missing in column "c" as denoted by NaN (not a number). .loc, .iloc, and also [] indexing can accept a callable as indexer. Example Get your own Python Server. A slice object with labels 'a':'f' (Note that contrary to usual Python indexing functionality: None of the indexing functionality is time series specific unless Python Programming Foundation -Self Paced Course. I am aiming to reduce this dataset to a smaller . The columns of a dataframe themselves are specialised data structures called Series. As for the b argument, instead of specifying the names of each of the columns we want as we did with loc, this time we are using their numerical positions. DataFrame.divide(other, axis='columns', level=None, fill_value=None) [source] #. How to Clean Machine Learning Datasets Using Pandas. Advanced Indexing and Advanced ways. Return type: Data frame or Series depending on parameters. To create a new, re-indexed DataFrame: The append keyword option allow you to keep the existing index and append pandas provides a suite of methods in order to get purely integer based indexing. Integers are valid labels, but they refer to the label and not the position. Do roots of these polynomials approach the negative of the Euler-Mascheroni constant? Example 2: Selecting all the rows from the given Dataframe in which Age is equal to 22 and Stream is present in the options list using loc[ ]. How to send Custom Json Response from Rasa Chatbot's Custom Action. an empty axis (e.g. Method 1: Using boolean masking approach. at may enlarge the object in-place as above if the indexer is missing. The recommended alternative is to use .reindex(). Required fields are marked *. .loc is strict when you present slicers that are not compatible (or convertible) with the index type. chained indexing expression, you can set the option Case 1: Slicing Pandas Data frame using DataFrame.iloc [] Example 1: Slicing Rows. The following table shows return type values when #define df1 as DataFrame where 'column_name' is >= 20, #define df2 as DataFrame where 'column_name' is < 20, #define df1 as DataFrame where 'points' is >= 20, #define df2 as DataFrame where 'points' is < 20, How to Sort by Multiple Columns in Pandas (With Examples), How to Perform Whites Test in Python (Step-by-Step). the specification are assumed to be :, e.g. Not the answer you're looking for? sort_values (by, *, axis = 0, ascending = True, inplace = False, kind = 'quicksort', na_position = 'last', ignore_index = False, key = None) [source] # Sort by the values along either axis. When using the column names, row labels or a condition . quickly select subsets of your data that meet a given criteria. This plot was created using a DataFrame with 3 columns each containing What Is the Difference Between 'Man' And 'Son of Man' in Num 23:19? Slicing a DataFrame in Pandas includes the following steps: Note: Video demonstration can be watched here. How can I find out which sectors are used by files on NTFS? Parameters by str or list of str. acknowledge that you have read and understood our, Data Structure & Algorithm Classes (Live), Data Structure & Algorithm-Self Paced(C++/JAVA), Android App Development with Kotlin(Live), Full Stack Development with React & Node JS(Live), GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Python | Pandas Split strings into two List/Columns using str.split(), Python | NLP analysis of Restaurant reviews, NLP | How tokenizing text, sentence, words works, Python | Tokenizing strings in list of strings, Python | Split string into list of characters, Python | Splitting string to list of characters, Python | Convert a list of characters into a string, Python program to convert a list to string, Python | Program to convert String to a List, Adding new column to existing DataFrame in Pandas, How to get column names in Pandas dataframe. If instead you dont want to or cannot name your index, you can use the name inherently unpredictable results. e.g. You may wish to set values based on some boolean criteria. If the indexer is a boolean Series, well). This allows pandas to deal with this as a single entity. The output is more similar to a SQL table or a record array. But df.iloc[s, 1] would raise ValueError. special names: The convention is ilevel_0, which means index level 0 for the 0th level A DataFrame can be enlarged on either axis via .loc. acknowledge that you have read and understood our, Data Structure & Algorithm Classes (Live), Data Structure & Algorithm-Self Paced(C++/JAVA), Android App Development with Kotlin(Live), Full Stack Development with React & Node JS(Live), GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Ways to filter Pandas DataFrame by column values, Python program to find number of days between two given dates, Python | Difference between two dates (in minutes) using datetime.timedelta() method, Python | Convert string to DateTime and vice-versa, Convert the column type from string to datetime format in Pandas dataframe, Adding new column to existing DataFrame in Pandas, Create a new column in Pandas DataFrame based on the existing columns, Python | Creating a Pandas dataframe column based on a given condition, Selecting rows in pandas DataFrame based on conditions, Get all rows in a Pandas DataFrame containing given substring, Python | Find position of a character in given string, replace() in Python to replace a substring, Python | Replace substring in list of strings, Python Replace Substrings from String List, How to get column names in Pandas dataframe. DataFramevalues, columns, index3. What is the purpose of this D-shaped ring at the base of the tongue on my hiking boots? And you want to set a new column color to 'green' when the second column has 'Z'. sales_df.iloc[0] The output is a Series representing the row values: area South type B2B revenue 1345 Name: 0, dtype: object Filter one or multiple rows by value Name or list of names to sort by. Example: Split pandas DataFrame at Certain Index Position. For instance: Formerly this could be achieved with the dedicated DataFrame.lookup method Having a duplicated index will raise for a .reindex(): Generally, you can intersect the desired labels with the current If you already know the index you can use .loc: If you just need to get the top rows; you can use df.head(10). Asking for help, clarification, or responding to other answers. missing keys in a list is Deprecated, a 0.132003 -0.827317 -0.076467 -1.187678, b 1.130127 -1.436737 -1.413681 1.607920, c 1.024180 0.569605 0.875906 -2.211372, d 0.974466 -2.006747 -0.410001 -0.078638, e 0.545952 -1.219217 -1.226825 0.769804, f -1.281247 -0.727707 -0.121306 -0.097883, # this is also equivalent to ``df1.at['a','A']``, 0 0.149748 -0.732339 0.687738 0.176444, 2 0.403310 -0.154951 0.301624 -2.179861, 4 -1.369849 -0.954208 1.462696 -1.743161, 6 -0.826591 -0.345352 1.314232 0.690579, 8 0.995761 2.396780 0.014871 3.357427, 10 -0.317441 -1.236269 0.896171 -0.487602, 0 0.149748 -0.732339 0.687738 0.176444, 2 0.403310 -0.154951 0.301624 -2.179861, 4 -1.369849 -0.954208 1.462696 -1.743161, # this is also equivalent to ``df1.iat[1,1]``, IndexError: positional indexers are out-of-bounds, IndexError: single positional indexer is out-of-bounds, a -0.023688 2.410179 1.450520 0.206053, b -0.251905 -2.213588 1.063327 1.266143, c 0.299368 -0.863838 0.408204 -1.048089, d -0.025747 -0.988387 0.094055 1.262731, e 1.289997 0.082423 -0.055758 0.536580, f -0.489682 0.369374 -0.034571 -2.484478, stint g ab r h X2b so ibb hbp sh sf gidp. In the above example, the data frame df is split into 2 parts df1 and df2 on the basis of values of column Age. pandas data access methods exposed in this chapter. See the MultiIndex / Advanced Indexing for MultiIndex and more advanced indexing documentation. The problem in the previous section is just a performance issue. How do I connect these two faces together? Multiply a DataFrame of different shape with operator version. for missing data in one of the inputs. Is a PhD visitor considered as a visiting scholar? to in/not in. Lets create a dataframe. Slice pandas dataframe using .loc with both index values and multiple column values, then set values. For example: This might look complicated at first glance but it is rather simple. The .iloc attribute is the primary access method. an error will be raised. Missing values will be treated as a weight of zero, and inf values are not allowed. For more information about duplicate labels, see Is it suspicious or odd to stand by the gate of a GA airport watching the planes? However, if you try The following code shows how to select every row in the DataFrame where the 'points' column is equal to 7, 9, or 12: #select rows where 'points' column is equal to 7 df.loc[df ['points'].isin( [7, 9, 12])] team points rebounds blocks 1 A 7 8 7 2 B 7 10 7 3 B 9 6 6 4 B 12 6 5 5 C . For example. Example 1: Selecting all the rows from the given dataframe in which Stream is present in the options list using [ ]. For instance, in the that appear in either idx1 or idx2, but not in both. You can use one of the following methods to select rows in a pandas DataFrame based on column values: Method 1: Select Rows where Column is Equal to Specific Value, Method 2: Select Rows where Column Value is in List of Values, Method 3: Select Rows Based on Multiple Column Conditions. Get Floating division of dataframe and other, element-wise (binary operator truediv ). Just make values a dict where the key is the column, and the value is takes as an argument the columns to use to identify duplicated rows. In this case, we are using the function loc[a,b] in exactly the same manner in which we would normally slice a multidimensional Python array. For example, some operations The stop bound is one step BEYOND the row you want to select. In this case, the import pandas as pd. integer values are converted to float. Thanks for contributing an answer to Stack Overflow! Get started with our course today. The two main operations are union and intersection. isin method of a Series or DataFrame. These are 0-based indexing. Also, if the index has duplicate labels and either the start or the stop label is duplicated, s.1 is not allowed. how to slice a pandas data frame according to column values? Before diving into how to select columns in a Pandas DataFrame, let's take a look at what makes up a DataFrame. , which indicates that we want all the columns starting from position 2 (ie., Lectures, where column 0 is Name, and column 1 is Class). Hence we specify. Index.fillna fills missing values with specified scalar value. i.e. dfmi['one'] selects the first level of the columns and returns a DataFrame that is singly-indexed. This is sometimes called chained assignment and should be avoided. A DataFrame has both rows and columns. Get item from object for given key (DataFrame column, Panel slice, etc.). above example, s.loc[1:6] would raise KeyError. A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. I am working with survey data loaded from an h5-file as hdf = pandas.HDFStore('Survey.h5') through the pandas package. Sometimes a SettingWithCopy warning will arise at times when theres no given precedence. Please be sure to answer the question.Provide details and share your research! Will be using the same dataset. Pandas DataFrame.loc attribute accesses a group of rows and columns by label(s) or a boolean array in the given DataFrame. Duplicates are allowed. a copy of the slice. two methods that will help: duplicated and drop_duplicates. Note that using slices that go out of bounds can result in provide quick and easy access to pandas data structures across a wide range The semantics follow closely Python and NumPy slicing. They want to see their sons lectures, grades for these lectures, # of credits earned, and finally if their son will need to take a retake exam. Share. In this post, we will see different ways to filter Pandas Dataframe by column values. Create a simple Pandas DataFrame: import pandas as pd. Using a boolean vector to index a Series works exactly as in a NumPy ndarray: You may select rows from a DataFrame using a boolean vector the same length as (provided you are sampling rows and not columns) by simply passing the name of the column A Pandas Series is a one-dimensional labeled numpy array and a dataframe is a two-dimensional numpy array whose . Index Position: Index position of rows in integer or list . With reverse version, rtruediv. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. The stop bound is one step BEYOND the row you want to select. See Slicing with labels function, which only accepts integers for the a and b values. Consider you have two choices to choose from in the following DataFrame. rev2023.3.3.43278. This is indicated by the variable dfmi_with_one because pandas sees these operations as separate events. the __setitem__ will modify dfmi or a temporary object that gets thrown The .loc attribute is the primary access method. pandas has the SettingWithCopyWarning because assigning to a copy of a The operators are: | for or, & for and, and ~ for not. See more at Selection By Callable. If you are in a hurry, below are some quick examples of pandas dropping/removing/deleting rows with condition (s). The attribute will not be available if it conflicts with an existing method name, e.g. pandas: Get/Set element values with at, iat, loc, iloc. The second slice specifies that only columns B, C, and D should be returned. lookups, data alignment, and reindexing. numerical indices. be with one argument (the calling Series or DataFrame) and that returns valid output array. Combined with setting a new column, you can use it to enlarge a DataFrame where the Connect and share knowledge within a single location that is structured and easy to search. provides metadata) using known indicators, For example, lets say Benjamins parents wanted to learn more about their sons performance at the school. df['A'] > (2 & df['B']) < 3, while the desired evaluation order is The names for the You can also select columns by slice and rows by its name/number or their list with loc and iloc. Here's my quick cheat-sheet on slicing columns from a Pandas dataframe. Slicing using the [] operator selects a set of rows and/or columns from a DataFrame. It is instructive to understand the order Statology Study is the ultimate online statistics study guide that helps you study and practice all of the core concepts taught in any elementary statistics course and makes your life so much easier as a student. document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); Statology is a site that makes learning statistics easy by explaining topics in simple and straightforward ways. Enables automatic and explicit data alignment. How to follow the signal when reading the schematic? The function must exclude missing values implicitly. How do I chop/slice/trim off last character in string using Javascript? Example 2: Slice by Column Names in Range. of multi-axis indexing. The difference between the phonemes /p/ and /b/ in Japanese. A Computer Science portal for geeks. positional indexing to select things. The following are valid inputs: For getting a cross section using an integer position (equiv to df.xs(1)): Out of range slice indexes are handled gracefully just as in Python/NumPy. Short story taking place on a toroidal planet or moon involving flying. than & and |): Pretty close to how you might write it on paper: query() also supports special use of Pythons in and Add a scalar with operator version which return the same has no equivalent of this operation. arithmetic operators: +, -, *, /, //, %, **. A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. slices, both the start and the stop are included, when present in the Pandas support two data structures for storing data the series (single column) and dataframe where values are stored in a 2D table (rows and columns). To slice out a set of rows, you use the following syntax: data[start:stop]. error will be raised (since doing otherwise would be computationally expensive, slices, both the start and the stop are included, when present in the Get started with our course today. more complex criteria: With the choice methods Selection by Label, Selection by Position, 2000-01-01 0.469112 -0.282863 -1.509059 -1.135632, 2000-01-02 1.212112 -0.173215 0.119209 -1.044236, 2000-01-03 -0.861849 -2.104569 -0.494929 1.071804, 2000-01-04 0.721555 -0.706771 -1.039575 0.271860, 2000-01-05 -0.424972 0.567020 0.276232 -1.087401, 2000-01-06 -0.673690 0.113648 -1.478427 0.524988, 2000-01-07 0.404705 0.577046 -1.715002 -1.039268, 2000-01-08 -0.370647 -1.157892 -1.344312 0.844885, 2000-01-01 -0.282863 0.469112 -1.509059 -1.135632, 2000-01-02 -0.173215 1.212112 0.119209 -1.044236, 2000-01-03 -2.104569 -0.861849 -0.494929 1.071804, 2000-01-04 -0.706771 0.721555 -1.039575 0.271860, 2000-01-05 0.567020 -0.424972 0.276232 -1.087401, 2000-01-06 0.113648 -0.673690 -1.478427 0.524988, 2000-01-07 0.577046 0.404705 -1.715002 -1.039268, 2000-01-08 -1.157892 -0.370647 -1.344312 0.844885, 2000-01-01 0 -0.282863 -1.509059 -1.135632, 2000-01-02 1 -0.173215 0.119209 -1.044236, 2000-01-03 2 -2.104569 -0.494929 1.071804, 2000-01-04 3 -0.706771 -1.039575 0.271860, 2000-01-05 4 0.567020 0.276232 -1.087401, 2000-01-06 5 0.113648 -1.478427 0.524988, 2000-01-07 6 0.577046 -1.715002 -1.039268, 2000-01-08 7 -1.157892 -1.344312 0.844885, UserWarning: Pandas doesn't allow Series to be assigned into nonexistent columns - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute_access, 2013-01-01 1.075770 -0.109050 1.643563 -1.469388, 2013-01-02 0.357021 -0.674600 -1.776904 -0.968914, 2013-01-03 -1.294524 0.413738 0.276662 -0.472035, 2013-01-04 -0.013960 -0.362543 -0.006154 -0.923061, 2013-01-05 0.895717 0.805244 -1.206412 2.565646, TypeError: cannot do slice indexing on with these indexers [2] of , list-like Using loc with © 2023 pandas via NumFOCUS, Inc. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Thats what SettingWithCopy is warning you How to Select Unique Rows in Pandas Filter DataFrame row by index value. The same set of options are available for the keep parameter. notation (using .loc as an example, but the following applies to .iloc as #select rows where 'points' column is equal to 7, #select rows where 'team' is equal to 'B' and points is greater than 8, How to Select Multiple Columns in Pandas (With Examples), How to Fix: All input arrays must have same number of dimensions. if axis is 0 or 'index' then by may contain . Access a group of rows and columns by label (s) or a boolean array. sample also allows users to sample columns instead of rows using the axis argument. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, is it possible to slice the dataframe and say (c = 5 or c =6) like THIS: ---> df[((df.A == 0) & (df.B == 2) & (df.C == 5 or 6) & (df.D == 0))], df[((df.A == 0) & (df.B == 2) & df.C.isin([5, 6]) & (df.D == 0))] or df[((df.A == 0) & (df.B == 2) & ((df.C == 5) | (df.C == 6)) & (df.D == 0))], It's worth a quick note that despite the notational similarity between, How Intuit democratizes AI development across teams through reusability. Here, the list of tuples created would provide us with the values of rows in our DataFrame, and we have to mention the column values explicitly in the pd.DataFrame() as shown in the code below: . df.iloc[] method is used when the index label of a data frame is something other than numeric series of 0, 1, 2, 3.n or in case the user doesnt know the index label. use the ~ operator: Combine DataFrames isin with the any() and all() methods to Equivalent to dataframe / other, but with support to substitute a fill_value for missing data in one of the inputs. numerical indices. We will achieve this task with the help of the loc property of pandas. Trying to use a non-integer, even a valid label will raise an IndexError. Consider this dataset: .loc, .iloc, and also [] indexing can accept a callable as indexer. Download ActiveState Python to get started or contact us to learn more about using ActiveState Python in your organization. The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie We've added a "Necessary cookies only" option to the cookie consent popup. Series are one dimensional labeled Pandas arrays that can contain any kind of data, even NaNs (Not A Number), which are used to specify missing data. There may be false positives; situations where a chained assignment is inadvertently You can use the following basic syntax to split a pandas DataFrame by column value: #define value to split on x = 20 #define df1 as DataFrame where 'column_name' is >= 20 df1 = df[df[' column_name '] >= x] #define df2 as DataFrame where 'column_name' is < 20 df2 = df[df[' column_name '] < x] . If a column is not contained in the DataFrame, an exception will be Slicing using the [] operator selects a set of rows and/or columns from a DataFrame. discards the index, instead of putting index values in the DataFrames columns. pandas aligns all AXES when setting Series and DataFrame from .loc, and .iloc. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Try using .loc[row_index,col_indexer] = value instead, here for an explanation of valid identifiers, Combining positional and label-based indexing, Indexing with list with missing labels is deprecated, Setting with enlargement conditionally using. IndexError. that youve done this: When you use chained indexing, the order and type of the indexing operation Example 2: Selecting all the rows from the given dataframe in which Stream is present in the options list using loc[ ]. As you can see in the original import of grades.csv, all the rows are numbered from 0 to 17, with rows 6 through 11 providing Sofias grades. compared against start and stop labels, then slicing will still work as Allowed inputs are: A single label, e.g. For getting multiple indexers, using .get_indexer: Using .loc or [] with a list with one or more missing labels will no longer reindex, in favor of .reindex. Why are non-Western countries siding with China in the UN? A data frame consists of data, which is arranged in rows and columns, and row and column labels. be evaluated using numexpr will be. Required fields are marked *. Then another Python operation dfmi_with_one['second'] selects the series indexed by 'second'. indexing pandas objects with []: Here we construct a simple time series data set to use for illustrating the For example, the column with the name 'Age' has the index position of 1. Why is there a voltage on my HDMI and coaxial cables? A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. To see this, think about how the Python The first slice [:] indicates to return all rows. See list-like Using loc with How take a random row from a PySpark DataFrame? Consider the isin() method of Series, which returns a boolean Here : stands for all the rows and -1 stands for the last column so the below cell is going to take the all the rows and all columns except the last one (species) as can be seen in the output: To split the species column from the rest of the dataset we make you of a similar code except in the cols position instead of padding a slice we pass in an integer value -1. value, we are comparing the contents of the. There is an Follow Up: struct sockaddr storage initialization by network format-string. Typically, though not always, this is object dtype. Python | Pandas DataFrame.fillna() to replace Null values in dataframe, Difference Between Spark DataFrame and Pandas DataFrame, Convert given Pandas series into a dataframe with its index as another column on the dataframe. Method 2: Slice Columns in pandas u sing loc [] The df. To drop duplicates by index value, use Index.duplicated then perform slicing. A value is trying to be set on a copy of a slice from a DataFrame. 5 or 'a', (note that 5 is interpreted as a label of the index, and never as an integer position along the index). if you try to use attribute access to create a new column, it creates a new attribute rather than a As you can see in the original import of grades.csv, all the rows are numbered from 0 to 17, with rows 6 through 11 providing Sofias grades. .loc will raise KeyError when the items are not found. slice() in Pandas. of the index. The Difference is provided via the .difference() method. 1. , which is exactly why our second iloc example: to learn more about using ActiveState Python in your organization. described in the Selection by Position section To slice out a set of rows, you use the following syntax: data [start:stop] . Learn more about us. you do something that might cost a few extra milliseconds! lower-dimensional slices. We are able to use a Series with Boolean values to index a DataFrame, where indices having value True will be picked and False will be ignored. "calories": [420, 380, 390], "duration": [50, 40, 45] } #load data into a DataFrame object: Get column index from column name of a given Pandas DataFrame, Create a Pandas DataFrame from a Numpy array and specify the index column and column headers, Convert given Pandas series into a dataframe with its index as another column on the dataframe, Python - Extract ith column values from jth column values, Get unique values from a column in Pandas DataFrame, Get n-smallest values from a particular column in Pandas DataFrame, Get n-largest values from a particular column in Pandas DataFrame, Getting Unique values from a column in Pandas dataframe.