Let’s consider this Dataframe: I want to compute column D based on: The max value between: integer 0 A slice of column B at that row’s index So I have created a column C (all zeroes) in my dataframe in order use DataFrame.max(axis=1). However, short of using apply or looping over the DataFrame, I …
Tag: pandas
df.drop does not work properly, pandas python
I have this excel file that I would like to “normalize” with the below code by dropping the A and B columns and then dropping the Rows 1,2,3,5 and making the row 4 as header. But I keep getting this weird df that I dont understand the reason why Also: Answer You must explicitely set the column nam…
How to “describe” a column in pandas for python
I’m using pandas in python and I have a dataframe where one column is a timestamp and others contain data. The blue line stays constant for a while, then suddenly increases to zero, then at some point descends again to about -98 and stays there until it suddenly goes up to zero. What I need is a new col…
split a workbook into different workbooks with worksheets using python pandas
I have a list of transactions from the last 7 years in one big excel file. I m trying to create an excel workbook for each year that includes each months as worksheet. Im using a column called ‘date’ that has each transactions recorded as MM/DD/YYY. I split that column to single out my years and m…
How to make a python program that calculates a result for each row of the input table?
I am trying to make a Python program that will calculate a result based on a formula, given factors and an input dataframe. I have a number of cars (N_cars) on a given length of the road (l) and their average speed (v): I also know the factors needed for the formula for each category of car, and I know
When do I need to use a GeoSeries when creating a GeoDataFrame, and when is a list enough?
I define a polygon: and create a list of random points: I want to know which points are within the polygon. I create a GeoDataFrame with a column called points, by first converting the points list to GeoSeries: Then simply do: which returns a pandas.core.series.Series of booleans, indicating which points are …
Pandas: Counting number of times registers appear in rows in new columns for all rows
I have a dataframe like this: I need 3 new columns: ‘Times’ would count how many times the Player appears and in all the rows of that Player would appear the total number. So if Peter appears in 3 rows, here would show number 3 in all Peter rows. ‘Serie 1’ would count how many times th…
How can I make a column into rows with pandas with a dynamic number of columns?
I am trying to convert a column of values into separate columns using pandas in python. So I have columns relating to shops and their products and the number of products each shop has could be different. For example: What I am trying to achieve would look something like this: If there are any shops that have …
How can I webscrape information in the html element and save it to an Excel row using Beautifulsoup and any excel writer(Pandas)? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I’m new to python and I’m doing it for my project. Can someone help me save it to …
to_json without header and index pandas
I have the following pandas DF How can I convert this DF to json to be like: My best try was: But I got this output: Bonus Doubt: Is it possible to parse only the values 1,2,3 and 4 of column data to int? Answer The first approach is to squeeze your dataframe before use to_json For the bonus, use