All Questions
Tagged with loc or lines-of-code
171 questions
1
vote
2
answers
98
views
Python Pandas Loc Columns Between 2 Dates
I am quite new to Pandas. I need to select/locate the records between 2 dates.
I have tried a range of methods, but cant seem to get it. I have included a cut down of sample of the CSV/Data I am ...
1
vote
1
answer
51
views
Diving and duplication row in DataFrame above a certain value
I have the dataframe below. If the value in "Volume" is greater than > 1000, I would like to divide the volume by two and duplicate the entire row. Any advise on how to do this in Python?...
6
votes
1
answer
3k
views
How do I hide generated files in a PR on GitHub?
When I am about to review a pull request on GitHub, I look at the lines of code changed to get an idea of how time-consuming the review will be.
However, many projects include a bunch of generated ...
3
votes
1
answer
119
views
Calculating the average of a specific row with loc, loc is not finding the row value
I'm new to Python and stackoverflow. So please forgive any shortcomings in my posting.
I want to calculate the row average of a specific row(e.g. Bahrain) and I'm having problem achieving it.
I used ...
0
votes
1
answer
65
views
Problems with loc function in python, doesn't find a label taht is in my dataframe [duplicate]
I have an issue with using the 'loc' function in Python. I would like to extract a specific row from my dataframe 'df', which contains movie titles along with their respective information. The problem ...
1
vote
1
answer
84
views
In python, drop a time range period
I would like to drop 30 minutes of data after column is -1.
I have a large dataset and I need to remove 30 minutes from the dataframe after the column 'diff' == -1
I have the following code:
df12_3....
0
votes
2
answers
84
views
How to replace NaN values with the correspondent month and hour mean value
I'm trying to replace the NaN values from a DataFrame with the correspondent month and hour mean value of this DataFrame.
So let's say I have a DataFrame with generic measures where, randomly, there ...
0
votes
1
answer
50
views
traverse a list of dictionaries and store them into a separate column
https://github.com/ajayvd/DOUBT_SO/blob/main/doubt.csv
The above link contains the data frame and it contains 2 columns response_value & response_errors & The response_errors contains the ...
0
votes
1
answer
79
views
AND condition and strict equality in loc
I need to match the payment of invoices in the DocN column of df1 with the data in the TXT column in df2. Print the document (DocN) + the amount (DocSum) and the details of the corresponding payment (...
1
vote
1
answer
60
views
Create a column ranking order of records by date
Imagine I have the following dataframe with employees, their contract type (values could be Employee, Contractor and Agency). Also, one person can have more than 1 contract as you could see in the ...
0
votes
1
answer
812
views
Pandas: set column value based on other columns: Filtering Data and changing column values
New python programmer here. Sample data is shown below. I have a dataframe that has < 1,000 rows. That df came from reading an Excel workbook. The "Store" column has multiple kinds of ...
0
votes
1
answer
49
views
Search for LOV columns in dataframe and replace with codes using other dataframe
Imagine I have a dirty dataframe of employees with their ID, and Contract related information per country.
Some columns of this dataframe are LOV columns (depending on the country, some columns are ...
1
vote
1
answer
47
views
Confirm if LOV columns in a pandas dataframe complies with another mapping dataframe
I have 2 dataframes, one of them of employee information by Country, and another one with a mapping of possible values for LOV columns per country (depending on the country, the column may or may not ...
0
votes
1
answer
47
views
Python: Formating totals to showcase different formulas per row rather than just the total sums
I have a large dataset with different rows that I created using formulas and the grouped by function
# Create new column "iCPI"
grouped_sums['iCPI'] = grouped_sums['Budget Delivered'] / ...
-1
votes
2
answers
2k
views
How can I count words or tokens in my code?
There are all sorts of tools for counting lines of code in a source file or directory tree (e.g. cloc). There are also tools for counting words in a plain text file (wc).
How would I go about counting ...