Questions tagged [isin]

isin is a concept of checking if some value is contained in a list; That concept is used in Python with [pandas] and [numpy]

isin is a concept of checking if some value is contained in a list; That concept is used in Python with [pandas] and [numpy]

147 questions
0
votes
0 answers

Find records for repeated id in the following days based the first day's value using python

I'm trying to find the repeated ids based on the first day's value. For example, I have records for 4 days: import pandas as pd df = pd.DataFrame({'id':['1','2','5','4','2','3','5','4','2','5','2','3','3','4'], …
goosepea
  • 25
  • 1
  • 6
0
votes
1 answer

How to compare between each columns text value?

I want to compare with each columns in python. for instance : no. name name_convert contains 0 applepie apple True 1 applepie strawberry False 2 bananashake banana True 3 bananashake banana True I want to create contains columns.…
장정현
  • 3
  • 2
0
votes
1 answer

isin holidays only recognizing the first hour

I have created a class with the holidays in Spain class SpainBusinessCalendar(AbstractHolidayCalendar): rules = [ #Spain - If one holiday is on a Sunday, each Autonomous Community can change it to a Monday. Holiday('Año Nuevo', month=1,…
Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
0
votes
1 answer

How to conditionally create Pandas column using isin?

I have the following dataframe: {'population': {0: '38,928,346', 1: '2,877,797', 2: '43,851,044', 3: '77,265', 4: '32,866,272', 5: '97,929', 6: '45,195,774', 7: '2,963,243', 8: '25,499,884', 9: '9,006,398', 10: '10,139,177', 11: '393,244', 12:…
user3486773
  • 1,174
  • 3
  • 25
  • 50
0
votes
1 answer

Isin across 2 columns for groupby

How to use isin with or (?), when I know that my data to match in df1 will be distributed across 2 columns (Title, ID). Below code works if you delete ' or df1[df1.ID.isin(df2[column])] ' import pandas as pd df1 = pd.DataFrame({'Title': ['A1',…
Olka
  • 41
  • 6
0
votes
1 answer

How do I subset with .isin (seems like it doesn't work properly)?

I'm a student from Moscow State University and I'm doing a small research about suburban railroads. I crawled information from wikipedia about all stations in Moscow region and now I need to subset those, that are Moscow Central Diameter 1 (railway…
mieltn
  • 29
  • 5
0
votes
1 answer

Python pandas find element of one column in list of elements of another column

Here is my problem, where I want to find element of column A in list of elements of column B of a dataframe. As a result I want to to only keep those rows, where the element in A was found: df = pd.DataFrame({'A': [1, 2], 'B': [1,…
schluk5
  • 177
  • 2
  • 13
0
votes
2 answers

How can I derive a list of records that are not common across two dataframes?

I have two dataframes relating to securities - same structures / datatypes, just different sizes. df1: security_ID market_cap 0 ajax123 100000 1 apple456 10000 2 amazon513 20000 3 firefly312 …
0
votes
1 answer

pass both string and list to pandas .isin method

I am trying to pass both a string and a list to the pandas .isin() method. Here is my code below overall_months = ['APR', 'JUL', 'NOV', 'MAR', 'FEB', 'AUG', 'SEP', 'OCT', 'JAN', 'DEC', 'MAY', 'JUN', ['APR', 'JUL', 'NOV', 'MAR', 'FEB',…
Ryan
  • 75
  • 9
0
votes
1 answer

pandas isin() fail between dataframes with objects types columns

In [1]: import pandas as pd ...: a=pd.DataFrame([1,2,'a']) In [2]: a.isin([1,'a']) Out[2]: 0 0 True 1 False 2 True In [3]: a.isin(pd.DataFrame([1,'a'])) Out[3]: 0 0 True 1 False 2 False why isin cant find 'a' in a…
Franco Milanese
  • 402
  • 3
  • 7
0
votes
1 answer

Cycling through two csv's in Python/Pandas same code work with only one of the files

I made a code to pick the company number field in a "companies partner's" file and then compare with a file with companies list of a specific State of the Country, writing the result to a third file (final result: to have the partners of all the…
0
votes
2 answers

How do I check if dataframe column contains a string from another dataframe column and return adjacent cell in python pandas?

I have 2 dataframes, one containing a columnn of strings (df = data) which I need to categorise, and the other containing possible categories and search terms (df = categories). I would like to add a column to the "data" dataframe which returns a…
sab
  • 87
  • 2
  • 11
0
votes
1 answer

Pandas filter with Loc but exclude values in rows

1vat.loc[(vat['Sum of VAT'].isin([np.nan, 0])) & 2 (vat['Comment'] == 'Transactions 0DKK') & 3 (vat['Memo (Main)'] != '- None -'), 'Comment'] = 'Travel bill' 4vat[vat["Comment"] == "Travel bill"] I have a problem with line 3. It seems…
Darko86
  • 65
  • 1
  • 4
0
votes
1 answer

isin not working on ndarray of datetimes except with deprecation warning

I have the following two arrays of datetimes: datesA: datesA array([datetime.datetime(2000, 1, 4, 0, 0), datetime.datetime(2000, 1, 5, 0, 0), datetime.datetime(2000, 1, 6, 0, 0), datetime.datetime(2000, 1, 7, 0, 0), …
noemiemich
  • 114
  • 1
  • 8
0
votes
1 answer

Dataframe: pandas' isin working in one case but showing error in the other

I have the following code that analyzes the recent COVID19 data and finds cumulative confirmed cases for selected countries, which works fine. import pandas as pd import matplotlib.pyplot as…
hbaromega
  • 2,317
  • 2
  • 24
  • 32
1 2 3
9
10