{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Federico Trotta",
  "title_listed": "Use Pandas Data Frames More Effectively with the Top 7 Column Operations",
  "keywords": "Pandas,列操作",
  "domain": "数据处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/dominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d/",
  "publish_date": "2023-07",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "332b17fb7fd8",
  "collected_at": "2026-10-02T00:40:12",
  "title": "Use Pandas Data Frames More Effectively with the Top 7 Column Operations | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Use Pandas Data Frames More Effectively with the Top 7 Column Operations\nThe complete guide to performing the top 7 Pandas column operations, in different ways\n[Federico Trotta](https://towardsdatascience.com/author/federicotrotta/)\nJuly 6, 202317 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/07/1Mbufnja0kKygoHS3LjdASg.jpeg)\nWhen it comes to data analysis, [Pandas](https://pandas.pydata.org/) is the most used [Python](https://towardsdatascience.com/how-to-study-python-for-data-science-888a1ad649ae) library to manipulate and prepare the data for further analyses and Machine Learning.\nThe reality is that Pandas is a really flexible library and [can be used even to convert file formats](https://towardsdatascience.com/how-to-convert-a-csv-file-into-an-xlsx-one-with-python-and-pandas-27aabc279d69).\nHowever, even if we use some Pandas features barely every day, we spend a lot of time Googling how to do something in Pandas.\nI know, I caught you!\nBut let's be honest: some features are difficult to remember, maybe because we can reach the same goal with different methods. So, there's nothing to be ashamed of if we Google the same things every day.\nHowever, saving time is always a good idea. For this reason, in this article, we'll go through the 7 top features to manipulate Pandas columns. This way you won't need to Google them anymore: you just need to save this article (maybe, by bookmarking it) and return to it whenever you need it.\nThis is what you'll find here:\ntext\n\n```\nTable of contents:\n\nHow to create a new Pandas column\nHow to add a new column to a Pandas data frame\nHow to rename a column in Pandas\nHow to drop a Pandas column\nHow to find unique values in a Pandas column\nHow to transform a Pandas column into a list\nHow to sort a Pandas data frame for a column\n```\n\n* * *\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist), [Computer Science](https://roadmap.sh/computer-science) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n## How to create a new Pandas column\nFirst of all, let's remember that a Pandas column is also called a [Pandas series](https://pandas.pydata.org/docs/reference/api/pandas.Series.html). This means that a Pandas data frame is an ordered collection of Pandas series.\nThere are a few methods to create a new Pandas column. Let's see them all.\n### Create a Pandas column as a Pandas series\nThe correct method to create a Pandas column that is thought to \"live\" on its own is through the Pandas series method like so:\ntext\n\n```\n# Create a Panad series\nseries = pd.Series([6, 12, 18, 24])\n\n# Print Pandas series\nprint(series)\n\n>>>\n\n  0     6\n  1    12\n  2    18\n  3    24\n  dtype: int64\n```\n\nI said \"the correct method\" because, as we've said, a Pandas column is a Pandas series. So, if we just need a single column we should use this method if we'd like to be \"**formally** correct\".\n### Create a Pandas column as a Pandas data frame\nHowever, the reality is that we won't need a column on its own much often.\nSo, another way to create a Pandas column is by creating a new Pandas data frame with just one column: this way, we could enrich it in a second moment with other columns.\nWe can do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Create a Pandas column as a Pandas data frame\ndf = pd.DataFrame({'A': [1, 2, 3, 4]})\n\n# Print Pandas data frame\nprint(df)\n\n>>>\n\n     A\n  0  1\n  1  2\n  2  3\n  3  4\n```\n\nSo, here the difference with the previous example is that, in this case, the Pandas column has also the name. In this case, we've called it \"A\".\ntext\n\n```\nNOTE:\n\nIf we take a look more closely to what we've done here, we can see that\nwe can create a Pandas data frame as a dictionary.\n\nIn fact, \"A\" is the key and it's separated by a list of values\nby a colon. Then, both the keys and the values are inside curly braces.\n```\n\n### Create a Pandas column as a Pandas data frame, starting from a NumPy array\nOne of the superpowers of Pandas is that it can \"accept\" NumPy arrays as input values. In other words, we can create a data frame starting from a NumPy array.\nIn the case of a single column, we can create a one-dimensional array and transform it into a data frame: this results in a data frame with a single column.\nWe can do it like so:\ntext\n\n```\nimport numpy as np\nimport pandas as pd\n\n# Create a NumPy array\nvalues = np.array([5, 10, 15, 20])\n\n# Transform array into Pandas data frame\ndf = pd.DataFrame(values)\n\n# Print data frame\nprint(df)\n\n>>>\n\n    0\n0   5\n1  10\n2  15\n3  20\n```\n\n* * *\n## How to add a new column to a Pandas data frame\nThe possibility to add a new column to a Pandas data frame is somehow paired with the creation of a new column.\nWhat I mean here is that we first need to create a Pandas data frame, then a single Pandas column, then we need to add the column to the data frame.\nAlso in this case we have multiple possibilities to do so. Let's see them all.\n### Adding a new column to a Pandas data frame: the standard method\nThe standard method to add a new column to a Pandas data frame is to create the data frame, then create a separate column, then add it to the data frame.\nWe'll use this method throughout all the following examples. So, here's how we can do so:\ntext\n\n```\nimport pandas as pd\n\n# Create a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 4]})\n\n# Add a new column by using a list of values\ndf['B'] = [20, 30, 40, 50]\n\n# Print data frame\nprint(df)\n\n>>>\n\n   A   B\n0  1  20\n1  2  30\n2  3  40\n3  4  50\n```\n\nSo, let's analyze what we've done step by step:\n  1. We've created a Pandas data frame with the method `pd.DataFrame()`.\n  2. We've created a new column with `df['B']`, meaning we called this new column \"B\".\n  3. We've assigned the values to the newly created column, with a list of numbers.\n\n\nSo, what's another method to create a new column? Is by using **a list of numbers** , if we already have a data frame.\n### Adding a new column to a Pandas data frame: applying functions\nThe power of the standard method to add a new column to an existing data frame gives us the possibility to create a new column and add it to an existing data frame, all in one line of code.\nFor example, say that we want to create two new columns as a combination of an existing column. We can do so by applying functions to existing columns like so:\ntext\n\n```\nimport pandas as pd\n\n# Create a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 4]})\n\n# Create a column doubling the values of column A\ndf['B'] = df['A'] * 2\n\n# Apply lambda function to column A to create column C\ndf['C'] = df['A'].apply(lambda x: x ** 2)\n\n# Print data frame\nprint(df)\n\n>>>\n\n   A  B   C\n0  1  2   1\n1  2  4   4\n2  3  6   9\n3  4  8  16\n```\n\nSo, here's what we've done:\n  1. We've created a Pandas column (\"A\") as a data frame.\n  2. We've created column \"B\" by doubling the values of column \"A\".\n  3. We've created column \"C\" by applying a lambda function to column \"A\". In particular, in this case, we're squaring the values of column \"A\".\n\n\nAll of these columns are stored together in a unique data frame.\n### Adding a new column to a Pandas data frame: using Pandas series or single Pandas columns\nOf course, we can add columns to a Pandas data frame even when the columns are Pandas series or Pandas data frame.\nHere's how we can do so:\ntext\n\n```\nimport pandas as pd\n\n# Create a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 4]})\n\n# Create a new column using pd.Series()\nvalues = pd.Series([5, 10, 15, 20]) # Create series\ndf['B'] = values # Add series to data frame as a column\n\n# Print data frame\nprint(df)\n\n>>>\n\n   A   B\n0  1   5\n1  2  10\n2  3  15\n3  4  20\n```\n\nSo, in the above case, we've created a Pandas series and, then, we've added it to the existing data frame by giving it a name.\nIn the case of a Pandas column created as a Pandas data frame, we have:\ntext\n\n```\nimport pandas as pd\n\n# Create a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [5, 6, 7, 8]})\n\n# Create a Pandas column as a data frame\ndf['C'] = pd.DataFrame({'C': [9, 10, 11, 12]})\n\n# Print data frame\nprint(df)\n\n>>>\n\n   A  B   C\n0  1  5   9\n1  2  6  10\n2  3  7  11\n3  4  8  12\n```\n\nAnd here we are.\ntext\n\n```\nNOTE:\n\nof course, the same methodology can be applied if we create a column\nas a NumPy array. We won't show the method here as \"the game\" should\nnow be clear.\n```\n\n* * *\n## How to rename a column in Pandas\nRenaming a Pandas column (or more than one) is another typical daily task we need to perform, but that we often can't remember.\nAlso, in this case, we have different methods to do so. Let's see them all.\n### How to rename a Pandas column: the rename() method\nWe can rename a Pandas column with the `rename()` method like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n\n# Renaming a single column\ndf = df.rename(columns={'A': 'NewA'})\n\n# Print data frame\nprint(df)\n\n>>>\n     NewA  B\n0     1    4\n1     2    5\n2     3    6\n\n```\n\nSo, it's like we're using a dictionary. Inside the `rename()` method, in fact, we need to pass the argument `columns` and specify the actual name and the new name inside curly braces, separating them with a column. Just like we do in dictionaries.\nOf course, we can use this method to rename multiple columns like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n\n# Rename multiple columns\ndf = df.rename(columns={'A': 'NewA', 'B': 'NewB'})\n\n# Print data frame\nprint(df)\n\n>>>\n\n    NewA  NewB\n0     1     4\n1     2     5\n2     3     6\n```\n\nAnd, again, it's as we'd work with dictionaries.\n### How to rename a Pandas column: the column attribute\nTo rename one Pandas column (or more than one, as we'll see) we can use the `columns` attribute like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n\n# Renaming all columns\ndf.columns = ['NewA', 'NewB']\n\n# Print data frame\nprint(df)\n\n>>>\n\n    NewA  NewB\n0     1     4\n1     2     5\n2     3     6\n```\n\nSo, in this case, the `columns` attribute gives us the possibility to use a list of strings to rename the columns.\n### How to rename a Pandas column: the set_axis() method\nTo rename one (or more than one) Pandas column we can use the `set_axis()` method like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n\n# Renaming all columns\ndf.set_axis(['NewA', 'NewB'], axis=1, inplace=True)\n\n# Print data frame\nprint(df)\n\n>>>\n\n     NewA  NewB\n0     1     4\n1     2     5\n2     3     6\n```\n\nSo, even in this case, we use a list of strings to rename the columns, but here we also need to pass the parameters `axis=1` and `inplace=True` because the `set_axis()` method sets the axes from zero, so is recreating them. This lets this method rename the columns.\n### How to rename a Pandas column: using lambda functions\nWhen we have to deal with strings as in the case of Pandas columns names, we can use lambda functions to modify the characters of the text.\nFor example, we may want (or need) to rename the columns by simply lowering the letters. We can do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'COLUMN_1': [1, 2, 3], 'COLUMN_2': [4, 5, 6]})\n\n# Renaming columns using a lambda function\ndf = df.rename(columns=lambda x: x.lower())  # Lowercase column names\n\n# Print data frame\nprint(df)\n\n>>>\n\n      column_1  column_2\n0         1         4\n1         2         5\n2         3         6\n```\n\nAnd here we are.\n* * *\n## How to drop a Pandas column\nDropping a Pandas column (or more than one) is another task we need to perform very often. Maybe because its values are not significant, maybe because its values are all `NULL` or for other reasons.\nTo perform this task we have two methods. Let's see them both.\n### How to drop a Pandas column: using the drop() method\nThe typical method to drop a Pandas column (or more than one) is by using the `drop()` method.\nHere the only thing to get in mind is to decide if we want to drop some columns and create a new data frame, or if we want to drop them and substitute the current data frame.\nLet me show the difference:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})\n\n# Drop one column and substitute the current data frame\ndf = df.drop('A', axis=1)\n\n# Print updated data frame\nprint(df)\n\n>>>\n\n   B  C\n0  4  7\n1  5  8\n2  6  9\n```\n\nSo, we've dropped the column \"A\" by using the `drop()` method specifying the name of the column we wanted to drop and the axis (`axis=1` in Pandas indicates the vertical direction and must be specified).\nIn this case, we've decided to substitute the data frame `df`. So, at the end of the process, the data frame `df` hasn't column \"A\".\nInstead, if we want to create another data frame, let's say we call id `df_2`, we have to do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9],\n      'D': [10, 11, 12]})\n\n# Drop one column and substitute the current data frame\ndf_2 = df.drop(['A', 'D'], axis=1)\n\n# Print new data frame\nprint(df_2)\n\n>>>\n\n   B  C\n0  4  7\n1  5  8\n2  6  9\n```\n\nSo, in this case, we've dropped two columns and created a new data frame with just columns \"B\" and \"C\".\nThis may be useful if we think we may need the original data frame `df` in the future, for further analyses.\n### How to drop a Pandas column: using the column index\nIn Pandas, columns can be singled out via the indexes. This means that we can drop them using indexes like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9],\n      'D': [10, 11, 12]})\n\n# Drop one column and append to a new data frame\ndf_2 = df.drop(df.columns[[0, 1]], axis=1)\n\n# Print new data frame\nprint(df_2)\n\n>>>\n\n   C    D\n0  7   10\n1  8   11\n2  9   12\n```\n\nSo, in this case, we've created a new data frame with just columns \"C\" and \"D\" and we've deleted columns \"A\" and \"B\" by using their indexes.\nRemembering that in Python we start counting from 0 (so, the first column is at index 0 and is column \"A\"), we have to say that this method may not be optimal if we have tens of columns for a simple reason: we should find the one (or the ones) we want to drop by counting them, which is subject to errors.\n* * *\n## How to find unique values in a Pandas column\nFinding unique values in a Pandas column is another task that we may need to perform daily, because duplicated values have to be treated in a particular way.\nAlso in this case we have a couple of methods to do so: one shows the duplicates in one column and the other removes them.\nLet's see them both.\n### How to find unique values in a Pandas column: using the value_counts() method to find duplicates\nIf we want to see if a Pandas column has duplicated values, and we also want to see how much are they, we can use the `value_counts()` like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 1, 3], 'B': [4, 5, 6, 7, 8,],\n    'C': [7, 8, 9, 10, 11]})\n\n# Find unique values in a Pandas column\nunique_values = df['A'].value_counts()\n\n# Print unique values\nprint(unique_values)\n\n>>>\n\n1    2\n3    2\n2    1\nName: A, dtype: int64\n```\n\nSo, the result here tells that:\n  1. The name of the column is \"A\" and the types are all \"int64\".\n  2. We have two 1s.\n  3. We have two 3s.\n  4. We have one 2.\n\n\nSo, it shows us the values and tells us how many of them are present in the column of our interest.\n### How to find unique values in a Pandas column: using the drop_duplicates() method to drop duplicates\nIf we want to drop the duplicates values in a Pandas column (because we know there are duplicates in it) we can use the `drop_duplicates()` method like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 1, 3], 'B': [4, 5, 6, 7, 8,],\n       'C': [7, 8, 9, 10, 11]})\n\n# Drop the duplicate values in a Pandas column\nunique_values = df['A'].drop_duplicates()\n\n# Print unique values\nprint(unique_values)\n\n>>>\n\n0    1\n1    2\n2    3\n```\n\nSo, we have removed the duplicates from column \"A\", creating a new Pandas column called `unique_values`.\n### How to find unique values in a Pandas column: studying a data frame\nAt this point, you may be asking:\" _Well, if I have a big data frame with tens of columns, how can I know that properly some columns have some duplicates_?\"\nGood question! The thing we can do is to first study the whole data frame.\nFor example, we may want to see if any columns have duplicates. We can do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame with duplicates\ndf = pd.DataFrame({'A': [1, 2, 2, 3, 4, 4], 'B': [5, 6, 6, 7, 8, 8]})\n\n# Check if there are duplicates in the DataFrame\nhas_duplicates = df.duplicated().any()\n\n# Print the result\nprint(has_duplicates)\n\n>>>\n\nTrue\n```\n\nSo, this code returns \"True\" if there are columns with duplicates and \"False\" if there aren't.\nAnd how about if we want to know the name of the columns that actually have duplicates? We can do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame with duplicates\ndf = pd.DataFrame({'A': [1, 2, 2, 3, 4, 4], 'B': [5, 6, 6, 7, 8, 8]})\n\n# Find duplicate rows\nduplicate_rows = df.duplicated()\n\n# Print the duplicate rows\nprint(df[duplicate_rows])\n\n>>>\n\n   A  B\n2  2  6\n5  4  8\n```\n\nAnd, so, the above code shows:\n  * The columns with the duplicates.\n  * The values of the duplicates.\n\n\nWe can now investigate any further with the `value_counts()` method or drop them with the `drop_duplicates()` method.\n* * *\n## How to transform a Pandas column into a list\nTransforming a Pandas column into a list is a useful feature that can give us the possibility to \"isolate\" all the values from a Pandas column to put them into a list. Then, we can do whatever we may need with a list, which is easily manageable (iterating, and so on).\nWe have two possibilities to do this transformation.\n### How to transform a Pandas column into a list: using the list() method\nThe `list()` method is a built-in Python function that converts an iterable object into a list. We can use it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 1, 3], 'B': [4, 5, 6, 7, 8,],\n    'C': [7, 8, 9, 10, 11]})\n\n# Transform Pandas column into a list\ncolumn_list = list(df['B'])\n\n# Print list\nprint(column_list)\n\n>>>\n\n[4, 5, 6, 7, 8]\n```\n\nSo, we've easily extracted our values and put them into a list.\n### How to transform a Pandas column into a list: using the to_list() method\nTo achieve the same result, we can use the `to_list()` method from Pandas. But take care: **it's available from Pandas version 1.2.0 or later**.\nWe can use it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [1, 2, 3, 1, 3], 'B': [4, 5, 6, 7, 8,],\n      'C': [7, 8, 9, 10, 11]})\n\n# Transform Pandas column into a list\ncolumn_list = df['B'].to_list()\n\n# Print list\nprint(column_list)\n\n>>>\n\n[4, 5, 6, 7, 8]\n```\n\nAnd, of course, we've obtained the same result as before.\n* * *\n## How to sort a Pandas data frame for a column\nThere are a lot of situations in which we need to sort our columns. By sorting we mean ordering, so we can choose to order the data in ascending or descending way.\nWe can reach this goal with the following methods.\n### How to sort a Pandas data frame for a column: using the sort_values() method\nTo sort a Pandas data frame for a column, we can use the `sort_values()`like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [10, 2, 7, 1, 15], 'B': [4, 2, 6, 28, 8,],\n    'C': [7, 1, 9, 10, 19]})\n\n# Sort df for A in ascending order\ndf.sort_values('A', ascending=True, inplace=True)\n\n# Print sorted data frame\nprint(df)\n\n>>>\n\n    A   B   C\n3   1  28  10\n1   2   2   1\n2   7   6   9\n0  10   4   7\n4  15   8  19\n```\n\nSo, as we can see, the data frame has been sorted with column \"A\" in ascending order. In fact, if we check:\n  * In the initial data frame, in column \"A\" the number 1 is in the 4th position. In column \"B\", the number 28 is in the fourth position.\n  * In the sorted data frame, in column \"A\", the number 1 is in the first position. In column \"B\", the number 28 is in the first position.\n\n\nSo, we sort the data frame but we don't lose the relations between the values of the columns.\nA very useful feature of this method is that it can sort a column by putting `NaNs` as first values. We can do it like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [10, 0, 0, 1, 15], 'B': [4, 2, 6, 28, 8,],\n    'C': [7, 1, 15, 10, 19]})\n\n# Sort NaNs in the beginning\ndf.sort_values('A', ascending=True, inplace=True)\n\n# Print sorted data frame\nprint(df)\n\n>>>\n\n    A   B   C\n1   0   2   1\n2   0   6  15\n3   1  28  10\n0  10   4   7\n4  15   8  19\n```\n\nAnd here we are.\n### How to sort a Pandas data frame for a column: using the sort_index() method\nWe can also sort a data frame for index value like so:\ntext\n\n```\nimport pandas as pd\n\n# Creating a DataFrame\ndf = pd.DataFrame({'A': [10, 2, 7, 1, 15], 'B': [4, 2, 6, 28, 8,],\n    'C': [7, 1, 9, 10, 19]})\n\n# Sort data frame for index\ndf.sort_index(inplace=True)\n\n# Print sorted data frame\nprint(df)\n\n>>>\n\n    A   B   C\n0  10   4   7\n1   2   2   1\n2   7   6   9\n3   1  28  10\n4  15   8  19\n```\n\nAnd, as we can see, the indexes are ordered (in ascending way).\n* * *\n## Conclusions\nIn this article, we've seen the top 7 operations on Pandas columns that we perform barely every day.\nThis guide will help you save a lot of time if you save it, because we've performed the same task in different ways so that you won't need to Google them anymore, saving a lot of time.\n* * *\nHi, I'm Federico Trotta and I'm a freelance Technical Writer.\nWant to collaborate with me? [Contact me](https://bio.link/federicotrotta).\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657183787_vf5bj8.png)\nWritten By\n## [Federico Trotta](https://towardsdatascience.com/author/federicotrotta/)\n[See all from Federico Trotta](https://towardsdatascience.com/author/federicotrotta/)\n[Data Science](https://towardsdatascience.com/tag/data-science/)[Federico Trotta](https://towardsdatascience.com/tag/federico-trotta/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Programming](https://towardsdatascience.com/tag/programming/)[Technology](https://towardsdatascience.com/tag/technology/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fdominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d%2F&title=Use%20Pandas%20Data%20Frames%20More%20Effectively%20with%20the%20Top%207%20Column%20Operations)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fdominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d%2F&title=Use%20Pandas%20Data%20Frames%20More%20Effectively%20with%20the%20Top%207%20Column%20Operations)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fdominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d%2F&text=Use%20Pandas%20Data%20Frames%20More%20Effectively%20with%20the%20Top%207%20Column%20Operations)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/1_2QvIWQkn3X5xAEElZjUkA.png)](https://towardsdatascience.com/top-10-vs-code-extensions-to-boost-productivity-526595b18325/)\n## [Top 10 VS Code Extensions to Boost Productivity](https://towardsdatascience.com/top-10-vs-code-extensions-to-boost-productivity-526595b18325/)\n[Programming](https://towardsdatascience.com/category/programming/)\nVS Code Extensions you should start using to improve developer productivity\n[Anushka Gupta](https://towardsdatascience.com/author/anushkagupta20128/)\nApril 29, 20225 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/09/1wufrom42nQEGeKOpr1rCdg.png)](https://towardsdatascience.com/nine-rules-for-running-rust-on-wasm-wasi-550cd14c252a/)\n## [Nine Rules for Running Rust on WASM WASI](https://towardsdatascience.com/nine-rules-for-running-rust-on-wasm-wasi-550cd14c252a/)\n[Programming](https://towardsdatascience.com/category/programming/)\nPractical Lessons from Porting range-set-blaze to this Container-Like Environment\n[Carl Kadie](https://towardsdatascience.com/author/carlmkadie/)\nSeptember 28, 202414 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/06/1RrSFNujGiMH88NVRNCm4jw.png)](https://towardsdatascience.com/the-battle-of-choropleths-part-2-altair-accaa4b46fb4/)\n## [The Battle of Choropleths - Part 2 - Altair](https://towardsdatascience.com/the-battle-of-choropleths-part-2-altair-accaa4b46fb4/)\n[Programming](https://towardsdatascience.com/category/programming/)\nUsing Altair to Create Stunning Choropleths\n[TheDataProf](https://towardsdatascience.com/author/francisadrianviernes/)\nJune 18, 20224 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/1rk9e5aguVHkzKpCmf2m26A.png)](https://towardsdatascience.com/multi-seasonal-time-series-decomposition-using-mstl-in-python-136630e67530/)\n## [Multi-Seasonal Time Series Decomposition using MSTL in Python](https://towardsdatascience.com/multi-seasonal-time-series-decomposition-using-mstl-in-python-136630e67530/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nFind out how to decompose multi-seasonal time series using MSTL, discover how MSTL works, and see MSTL in action on real world data.\n[Kishan Manani](https://towardsdatascience.com/author/kish.manani/)\nApril 28, 202215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/07/1W5mXHT3BmvQPznBa30jY9Q.png)](https://towardsdatascience.com/2-efficient-ways-of-creating-fancy-pictogram-charts-in-python-8b77d361d500/)\n## [2 Efficient Ways of Creating Fancy Pictogram Charts in Python](https://towardsdatascience.com/2-efficient-ways-of-creating-fancy-pictogram-charts-in-python-8b77d361d500/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat pictogram charts are, when to use them, and how to create them in Plotly and PyWaffle libraries\n[Elena Kosourova](https://towardsdatascience.com/author/elena-kosourova/)\nJuly 26, 20216 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/1JFjPaBMk8UB2TcJkt2W4LA-scaled.jpeg)](https://towardsdatascience.com/lstm-for-predictive-maintenance-on-pump-sensor-data-b43486eb3210/)\n## [LSTM for Predictive Maintenance on Pump Sensor Data](https://towardsdatascience.com/lstm-for-predictive-maintenance-on-pump-sensor-data-b43486eb3210/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nIn this article, we want to look at some time series analysis to explain the thought process in a predictive maintenance case\n[Jan Werth](https://towardsdatascience.com/author/janwerth/)\nAugust 10, 20213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/12/1OroODN404vwXakDOFkbUXg.jpeg)](https://towardsdatascience.com/debug-python-scripts-like-a-pro-78df2f3a9b05/)\n## [Debug Python Scripts Like a Pro](https://towardsdatascience.com/debug-python-scripts-like-a-pro-78df2f3a9b05/)\n[Programming](https://towardsdatascience.com/category/programming/)\nThe bad, the lovely, and the smart ways of debugging your Python code.\n[Thuwarakesh Murallie](https://towardsdatascience.com/author/thuwarakesh/)\nDecember 14, 20219 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/01/1CF_kBKKSJsmx9IB5_owFAg.jpeg)](https://towardsdatascience.com/entity-resolution-with-tigergraph-add-zingg-to-the-mix-95009471ca02/)\n## [Entity Resolution with TigerGraph? Add Zingg to the Mix!](https://towardsdatascience.com/entity-resolution-with-tigergraph-add-zingg-to-the-mix-95009471ca02/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAn open source tool that learns what to match (scale) and how to match (similarity) based on training data.\n[Sonal Goyal](https://towardsdatascience.com/author/sonalgoyal/)\nJanuary 21, 20224 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1pv2AJGKWmqbFC9NjAWXuCg-scaled.jpeg)](https://towardsdatascience.com/succeed-as-data-scientist-at-a-hackathon-without-data-being-provided-490ac46c9674/)\n## [Succeed as a Data Scientist in a Hackathon Without Data Being Provided?](https://towardsdatascience.com/succeed-as-data-scientist-at-a-hackathon-without-data-being-provided-490ac46c9674/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat to and what not to expect\n[Tim Loehr](https://towardsdatascience.com/author/mavengence/)\nOctober 12, 20205 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3642/image?etag=1780830904480&width=500&height=500) Check Your Biases ](https://towardsdatascience.com/check-your-biases-ba2685a7f799/ \"Check Your Biases\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4973/image?etag=1782232567105&width=500&height=500) Machine Learning Tricks, Learning with ChatGPT, and Other Recent Must-Reads ](https://towardsdatascience.com/machine-learning-tricks-learning-with-chatgpt-and-other-recent-must-reads-f277648a1921/ \"Machine Learning Tricks, Learning with ChatGPT, and Other Recent Must-Reads\")\n\n\nword word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word\n  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1\n",
  "metadata": {
    "title": "Use Pandas Data Frames More Effectively with the Top 7 Column Operations | Towards Data Science",
    "description": "The complete guide to performing the top 7 Pandas column operations, in different ways",
    "keywords": null,
    "author": "Federico Trotta",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Use Pandas Data Frames More Effectively with the Top 7 Column Operations",
    "og:description": "The complete guide to performing the top 7 Pandas column operations, in different ways",
    "og:url": "https://towardsdatascience.com/dominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/07/1Mbufnja0kKygoHS3LjdASg.jpeg",
    "og:image:width": "1280",
    "og:image:height": "682",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Federico Trotta",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "17 min read",
    "article:published_time": "2023-07-06T15:36:12.000Z",
    "article:modified_time": "2023-07-06T15:36:12.000Z",
    "article:author": "https://towardsdatascience.com/author/federicotrotta/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": "",
    "retried": true
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_000.txt",
      "chars": 297
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_001.txt",
      "chars": 158
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_002.txt",
      "chars": 186
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_003.txt",
      "chars": 266
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_004.txt",
      "chars": 232
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_005.txt",
      "chars": 235
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_006.txt",
      "chars": 348
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_007.txt",
      "chars": 311
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_008.txt",
      "chars": 285
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_009.txt",
      "chars": 159
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_010.txt",
      "chars": 250
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_011.txt",
      "chars": 267
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_012.txt",
      "chars": 243
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_013.txt",
      "chars": 266
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_014.txt",
      "chars": 351
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_015.txt",
      "chars": 271
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_016.txt",
      "chars": 303
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_017.txt",
      "chars": 312
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_018.txt",
      "chars": 310
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_019.txt",
      "chars": 301
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_020.txt",
      "chars": 272
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_021.txt",
      "chars": 270
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_022.txt",
      "chars": 259
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_023.txt",
      "chars": 265
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_024.txt",
      "chars": 353
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_025.txt",
      "chars": 348
    },
    {
      "language": "txt",
      "file": "attachments/332b17fb7fd8/code/block_026.txt",
      "chars": 324
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/07/1Mbufnja0kKygoHS3LjdASg.jpeg",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/000.jpeg",
      "bytes": 166112,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/1_2QvIWQkn3X5xAEElZjUkA.png",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/001.png",
      "bytes": 14917,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/09/1wufrom42nQEGeKOpr1rCdg.png",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/002.png",
      "bytes": 1728693,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/06/1RrSFNujGiMH88NVRNCm4jw.png",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/003.png",
      "bytes": 64493,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/1rk9e5aguVHkzKpCmf2m26A.png",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/004.png",
      "bytes": 951534,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/07/1W5mXHT3BmvQPznBa30jY9Q.png",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/005.png",
      "bytes": 640183,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/1JFjPaBMk8UB2TcJkt2W4LA-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/006.jpeg",
      "bytes": 521735,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/12/1OroODN404vwXakDOFkbUXg.jpeg",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/007.jpeg",
      "bytes": 179885,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/01/1CF_kBKKSJsmx9IB5_owFAg.jpeg",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/008.jpeg",
      "bytes": 74424,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1pv2AJGKWmqbFC9NjAWXuCg-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/332b17fb7fd8/images/009.jpeg",
      "bytes": 668532,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [],
  "retry_at": "2026-10-03T08:01:31",
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:49Z",
  "source_url": "https://towardsdatascience.com/dominate-pandas-data-frames-with-the-top-7-column-operations-2a11521e9e2d/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}