Currently I’m reading all excel files and appending the “data” sheet to an array from a given directory. The issue is that some of the excel files in the directory shouldn’t actually be there and don’t contain a “data” sheet. The program then breaks whenever it encoun…
Tag: pandas
My while function is not returning any value ! What am i doing wrong
Quite newbie to this ! i have a dataframe that looks like this: i have written that looks like this: the expected output is : When i run my function i dont have any result … I mean the flag is not working properly. All rows are set to None What wrong here ? Answer Use numpy.select for this since
How to use spacy to do Name Entity recognition on CSV file
I have tried so many things to do name entity recognition on a column in my csv file, i tried ne_chunk but i am unable to get the result of my ne_chunk in columns like so Instead after using this code, i got this error So, i am wondering if i could do this using spaCy which is another thing
imblearn.oversampling SMOTENC ValueError
This is my first time using SMOTENC to upsampling my categorical data. However, I’ve been getting error. Can you please advice what should I pass for categorical_features in SMOTENC? ERROR: Answer As per documentation: So, just replace the line with the line
Creating a new columns with maximum count of value in multiple columns
I have a dataframe that contains multiple columns as follow: I want to create a new column based on the player, competition and value of highest occurrence in Home column and Away column. Let’s say the name of a new column that I want to create is Team. I would like have a new column as follow: So it su…
pandas reshape multiple columns fails with KeyError
For a pandas dataframe of: defined by: I want to reshape to the following format: A: only results in a KeyError. How can I fix the reshape to work fine? Answer Here’s a way using stack:
How can I turn my DataFrame into a Radar Chart using Python?
I have a DataFrame I want to turn into a Radar Chart. The DataFrame looks like this when it’s ran… I repurposed some code I found on another Stack Overflow question pertaining to Pandas and Radar Charts and it works for the most part except I can’t get the values of Col B to align properly w…
Convert string (comma separated) to int list in pandas Dataframe
I have a Dataframe with a column which contains integers and sometimes a string which contains multiple numbers which are comma separated (like “1234567, 89012345, 65425774”). I want to convert that string to an integer list so it’s easier to search for specific numbers. Answer Since your co…
Is there the equivalent of to_markdown to read data?
With pandas 1.0.0 the use of .to_markdown() to show the content of a dataframe in this forum in markdown is going to proliferate. Is there a convenient way to load the data back into a dataframe? Maybe an option to .from_clipboard(markdown=True)? Answer None of the answers so far read the data from the clipbo…
Outlier removal Isolation Forest
I’ve been trying to remove outliers from my database using isolation forest, but I can’t figure out how. I’ve seen the examples for credit card fraud and Salary but I can’t figure out how to apply them on each column as my database consists of 3862900 rows and 19 columns. I’ve up…