• Register

Recent questions tagged python

0 votes
1 answer 6 views
Problems I am trying to update selected datetime64 values in a pandas data frame using the loc method to select rows satisfying a condition. However, instead of assigning the new date-time value it results in NaT. Here is a simplification of my code that shows the problem: ... as the second element in the new_date column. Any ideas on how this should be done or why this is not working as intended?
asked 5 days ago Marivoke 530 points
0 votes
1 answer 4 views
Why can't I perform arithmetic operations on a set. For example: {a+b} * c returns an error. When we try to do [a+b]*c, it returns a list. For instance: [4+5]*6 returns [9, 9, 9, 9, 9, 9]. But the same is not the result for the set. Why?
asked 5 days ago Marivoke 530 points
0 votes
1 answer 5 views
I require to remove all the special characters, puntuation and and speces from a string?
asked 6 days ago Daniel Anderson 2.1k points
0 votes
1 answer 4 views
I am facing the problem in my website. Can someone explain me why this is happening and how to solve this issue?
asked 6 days ago Daniel Anderson 2.1k points
0 votes
1 answer 4 views
Problem: #include <bits stdc++.h> using namespace std; int main() { int sum=0; int n; while(1){ cin >> n; sum += n; if(sum<0) break; cout << n << '\n'; } return 0; } What I have tried: sum = 0 while sum > 0: num = int(input()) sum = sum + num if sum >= 0: print(num) else: break
asked 6 days ago boris elin 620 points
0 votes
1 answer 4 views
I am trying to figure out why this error showing in my case and searching several website didn't get the desired result. In this website can someone can someone show me correct way to solve this ValueError: Must pass DataFrame with boolean values only.
asked 6 days ago Daniel Anderson 2.1k points
0 votes
1 answer 5 views
Can someone explain me why i am seeing this error that told me to use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $. How to solve it and what is reason behind this error?
asked 6 days ago Daniel Anderson 2.1k points
1 vote
1 answer 6 views
I am trying to open an https URL using the urlopen method in Python 3's urllib.request module. It seems to work fine, but the documentation warns that "[i]f neither cafile nor capath is specified, an HTTPS request will not do any verification of the server&rsquo;s ... get this list from? Is there any simple and cross-platform way to use the same list of certificates that my OS or browser uses?
asked 6 days ago Marivoke 530 points
0 votes
0 answers 5 views
I'm using Python's max function to find the largest integer in a dictionary called count, and the corresponding key (not quite sure if I'm saying it properly; my code probably explains itself better than I'm explaining it). The dictionary count is along the lines of {'a': 100, 'b': 210}, and ... there? If I had {'a': 120, 'b': 120, 'c': 100}, this would only find the first of a and b, not both.
asked 6 days ago NguyenTram 1k points
0 votes
0 answers 4 views
Customer_ID Country Gender Premium_account C_01 A M Yes C_02 A F No C_03 A F Yes C_04 A M Yes C_05 A M No C_06 B M No C_07 B M No C_08 B M Yes C_09 B F Yes C_10 B F No C_11 B F No Now I would like to plot for the Premium_account percentage ... this, hence I really cannot provide any coding of mine so far. I would appreciate any help that you can provide. Thanks in advance! Proportional bar plot
asked 6 days ago NguyenTram 1k points
0 votes
0 answers 4 views
I'm looking for a built-in Python data structure that can add a new element, remove an existing element, and choose a random element, all in better than O(n) time. I was hoping that set could do this, but AFAIK, the only way to choose a random ... that's built into Python, since I require efficiency and easy deployment. Unfortunately, Python does not seem to have built-in tree data types.
asked 6 days ago NguyenTram 1k points
0 votes
0 answers 4 views
I have a dataframe of almost 120000 records as follows. Also I have a mongoDB collection which looks exacly same as below dataframe ItemID ParentID ItemRating ItemPrice Qty A1 ItemA1 0 12 100 A2 ItemA2 0 15 200 B1 ItemB1 0 20 300 B2 ItemB2 0 25 400 B3 ItemB3 0 30 ... PyMongo update_many method by setting upsert=true. but I am not sure how can I do that ? how should I write my filter condition ?
asked 6 days ago NguyenTram 1k points