Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

panda - subset based on column value

import pandas as pd
import numpy as np
df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
                   'B': 'one one two three two two one three'.split(),
                   'C': np.arange(8), 'D': np.arange(8) * 2})
print(df)
sub_df = df.loc[df['A'] == 'foo'] # Subset based on specific A value
Comment

PREVIOUS NEXT
Code Example
Python :: how to check if a message includes a word discord.py 
Python :: flask for loops 
Python :: plot tf model 
Python :: fatal error detected failed to execute script 
Python :: take two numbers as inout in single line in python 
Python :: convert files from jpg to png and save in a new directory python 
Python :: view point cloud open3d 
Python :: remove duplicates without changing order python 
Python :: opencv histogram equalization 
Python :: concat dictionary of dataframes 
Python :: python selenium screenshot 
Python :: matplotlib add legend axis x 
Python :: how to make game on python 
Python :: pandas open text file 
Python :: mirror 2d numpy array 
Python :: how to do swapping in python without sort function 
Python :: save dataframe as csv 
Python :: get a list of all files python 
Python :: python how to get alphabet 
Python :: django.core.exceptions.FieldError: Unknown field(s) (author) specified for Comment 
Python :: from time import sleep, time 
Python :: how to insert sound in python 
Python :: python math cube root 
Python :: pythondatetime cheatsheet 
Python :: You did not provide the "FLASK_APP" environment variable 
Python :: django password change view 
Python :: Resource punkt not found. Please use the NLTK Downloader to obtain the resource: 
Python :: read_csv unnamed zero 
Python :: generate number of n bits python 
Python :: colab kaggle dataset 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =