I have a small question. How can I print all the texts belonging to that author by selecting the author from the csv that I read with the pandas below, can you help with the python code? (ex. I want to display all texts where eap is author.) Thank you! Answer Hey try out using loc() to get back the
Tag: pandas
Deleting rows based on time interval in pandas
I have a dataframe with datetime timestamps (every 1 minute). I’d like to increase the time interval between rows to 5 minutes. Basically keep rows 0, 5, 10 etc and remove the rest. How would I do that? Thanks Answer Firstly convert your date column to datetime dtype by using to_datetime() method(If its…
Remove symbols in dataset
I applied all preprocessing step, but I want to delete the rows that have English words or specific symbols, just i want words in the Arabic language without these symbols or English words that I mention it in below code. I applied the code, but when I print the dataset after cleaning, it still without cleani…
Networkx: Network graph from pandas dataframe
I have the following dataset: The dataframe shows when different investment firms have invested in the same Company during a year. I want to create a network graph of the Connections between the Firm_ID only. For example Ampersand and BancBoston have both invested in the same company and should therefore be c…
Get only numbers at the end (regex)
I’d like to get only the numbers (integers) at the end of the phrases below: I mean: 600, 1400, 100000. I’ll add each one of them to a database later. I tried to use regex: (?<=s)(d*s*)|(d*.d*)$ But it didn’t work properly. Any ideas? PS: We use dots, not commas to represent a thousand: 1…
Splitting columns and reformat date using pandas
I have an object, slist that I need to split, reformat the date, and export as a tab delimited file. For the splitting I think I’m tripping up understanding the first row? Here is slist: I’ve tried the following: Which gives me something like this: I’ve spent a ton of time trying to figure t…
combine multiple lines into one column
Here is my dataframe following the merging of two separate dataframes. In the [order] column, orders 2, 4 and 5, have multiple corresponding amounts in the [value] column. This is replicated elsewhere in the dataframe at random points. What can I do to merge these amounts so that I am left with one row in the…
Pandas To_Excel parsing problem – outputting only 1 file
Hello I have working code like this: Problem is: If I leave it like this it only outputs for first if. When I comment out that if section it will successfully output elif, but I can’t get it to output 2 files whatever I do. Any ideas? Error I’m getting for Acryptos: But if I comment out Autofarm a…
Drop data frames with condition contains (os.path.exists)
Trying to drop rows with path that doesn’t exist… Error: Answer As it stands, os.path.exists looks at the whole str representation of the column, not element-by-element. One way is to apply: If you print exists, it will be a boolean series saying which paths exist and which do not. inverted exist …
Cumulatively merge rows with the same index
In python pandas, I have a dataframe which looks something like this: Some of the dates are repeated, with a different count value. I would like to merge these values into one row like this: If it’s any help the data source is a CSV file. There is likely a way to do this in a for loop but I