r/pythoncoding • u/DevGenious • May 22 '23
nginx log parsing using pandas library
I have written a simple library to parse nginx log files.feel free to contribute
r/pythoncoding • u/DevGenious • May 22 '23
I have written a simple library to parse nginx log files.feel free to contribute
r/pythoncoding • u/AutoModerator • Jul 11 '22
Share what you're working on in this thread. What's the end goal, what are design decisions you've made and how are things working out? Discussing trade-offs or other kinds of reflection are encouraged!
If you include code, we'll be more lenient with moderation in this thread: feel free to ask for help, reviews or other types of input that normally are not allowed.
This recurring thread is a new addition to the subreddit and will be evaluated after the first few editions.
r/pythoncoding • u/AutoModerator • Jun 27 '22
Share what you're working on in this thread. What's the end goal, what are design decisions you've made and how are things working out? Discussing trade-offs or other kinds of reflection are encouraged!
If you include code, we'll be more lenient with moderation in this thread: feel free to ask for help, reviews or other types of input that normally are not allowed.
This recurring thread is a new addition to the subreddit and will be evaluated after the first few editions.
r/pythoncoding • u/EnZZ-yt • Sep 14 '20
I've been programming for like a year and I for some reason cant do anything. I was programming in c# for unity then I switched to python a few months ago, but I still was programming in unity every so often. I've spent a lot of time trying to learn I just cant seen to get past the very beginner stages like making a basic calculator, I cant even make a rock paper scissor game. I'm just struggling and i really enjoy programming I just need someone or something to set me on the right track. Any help is very much appropriated, i'm 15 and I'd like to get a job with python when I graduate from high school.
r/pythoncoding • u/[deleted] • Aug 30 '20
r/pythoncoding • u/frizzbuzz • Aug 15 '20
r/pythoncoding • u/rmk135 • Aug 13 '20
This tutorial shows how to build a CLI application following the dependency injection principle.
In this tutorial we will use:
Python 3
Csv files
Sqlite database
The tutorial is good for the beginners. Senior folks might find something interesting too.
r/pythoncoding • u/rmk135 • Aug 13 '20
r/pythoncoding • u/adhiragaven • Jul 20 '20
r/pythoncoding • u/cakethedog28272 • May 26 '20
INVITE LINK: https://discord.gg/RHCKYyR
We are a Discord Server who focuses on helping beginners improve their Python skills.
We have a great team of experienced programmers who are very active, friendly, and always willing to help anyone in need of it
Already we have over 1300 members and have quickly become the biggest beginner-focused Discord Server, with good reason.
We can’t wait to see you there! 😄
r/pythoncoding • u/Unlucky-Reindeer • Feb 25 '20
I'm brand new to python and I'm working on trying to get a column formatted as a short date in excel.
Here's what I have but I might be way off. It's an excel file with many tabs that will have different dates each time. I need it to format columns on many tabs as dates but right now I'm trying to do just one tab and one column. The excel file is called "events" and I'm trying to change column E.
import pandas as pd
writer = pd.ExcelWriter(wb2, engine='openpyxl', mode = 'a')
pd.core.format.header_style = None
events.to_excel(writer, sheet_name = 'Events',
index = False, startrow = 2,header = False)
workbook = writer.book
work_sheet = book[sheet_names[9]]
formatdict = {'num_format':'mm/dd/yyyy'}
fmt = workbook.add_format(formatdict)
worksheet.set_column('E:E', None, fmt)
it's not working though. Can anyone tell me what I'm doing wrong?
r/pythoncoding • u/neomatrix369 • Jan 31 '20
Mainly the lambda like or with .apply() like code styles? (for fast Pandas and Numpy execution), for e.g. vectorize code like this:
def some_function():
return group_series.apply(lambda x: x.astype(some_type)
.rolling(some_number).sum().shift(some_number))or even something like this:
def some_function():
return some_grouped_data_series.apply(
lambda x: x.some_function(
param1=value, param2=value2).mean().shift(some_number)
)Any suggestions I should try to vectorize the above, I tried a few things but it complains or I get undesired results.
r/pythoncoding • u/SMGxSpencer • Jan 18 '20
Python showing blank file when i search for it. When I click on it, it takes to back to VS 2017 and show my code again. I’m not sure what is going on or how to restore my file. It’s my homework for the week. And I lost it because I uninstall VS2017. Thanks an advance for the advice. Cheers!
r/pythoncoding • u/ImLearning0217 • Dec 15 '19
I’m a beginner so I’m sorry ahead time.. lol
I’m trying to define variables in a for statement? The variables are defined in one of two but in the other, nearly identical one, x1R, isn’t being defined. I’m sure it’s simple but I can’t figure it out for the life of me
CODE:
slope = (y2-y1)/(x2-x1)
if slope < 0:
left_lane.append(line)
if slope > 0:
right_lane.append(line)
#######################
for x1R, y1R, x2R, y2R in right_lane:
right_P = x1R, y1R, x2R, y2R = line.reshape(4)
#print(x1R)
for x1L, y1L, x2L, y2L in left_lane:
left_P = x1L, y1L, x2L, y2L = line.reshape(4)
#print(x1L)
print(x1L)
print(x1R)ERROR:
-9 Traceback (most recent call last): File "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/PyFiles/OpenCVLaneDetection/LaneTesting/t.py", line 172, in <module> print(x1R) NameError: name 'x1R' is not defined
r/pythoncoding • u/[deleted] • Dec 14 '19
joe = input(“have you heard of joe?”) if joe == (“who is joe”): print(“joe mama”); else: print(“you ruined it”);
r/pythoncoding • u/magicbunnyxo • Dec 14 '19
I am creating a bookstore in Python. The bookstore asks the user the book title, author and price - and it keeps the inventory and allows the user to show inventory increase book prices by 2%, decrease to reduce book prices by 2%, remove, and add a book. I need to add these two things to the program and I cannot figure it out.
Add a menu option to save the inventory to a file and another menu option to load inventory from the file. You should ask the user what file to save to and what file to retrieve from. The idea is that every evening at closing the inventory would be "dumped" from the lists or dictionaries you created into the file and it can be reloaded in the morning. In this way the information is not lost every time the program is terminated.
Convert your menu using object-oriented programming techniques into an object called CountryClubBookstore, a member of the Bookstore class. Be sure to add appropriate methods such as AddBook, SellBook, ReducePrices, etc. Ensure your class has the __init__ method appropriately defined.
for number one you can use your own destination on computer
---- this is my code -----
cash_balance = 1000
class Book():
def __init__(self,title,author,price):
self.Title=title
self.Author=author
self.Price=price
def __str__(self):
str= eval("Book Name:"+self.Title+"\nAuthor:"+self.Author+"\nPrice:"+self.Price)
return str
def Menu():
print("Menu\n A) Add Book \n B) Sell Book \n C) Reduce Book Prices by 2% \n D) Increase Book Prices by 2% \n V) Display Inventory \n Q) Quit \n Choose one:", end="")
def add_book(book_list):
cash_balance = 1000
print("Adding a book")
title = input("Enter book name:")
author = input("Enter author name:")
price = eval(input("Enter price amount:"))
book = Book(title,author,price)
book_list.append(book)
cash_balance = cash_balance-(price * 0.90)
print ("Updated balance",cash_balance)
def sell_book(book_list):
check = input("Enter book name:")
if check in book_list:
print("Book in stock. Would you like to sell? Y/N").upper()
if "Y":
print("Selling book now")
title = input("Enter book name:")
author = input("Enter author name:")
price = input("Enter price amount:")
book = Book(title,author,price)
book_list.pop(book)
print("Updated balance is",cash_balance + price)
elif "N":
print("Bookstore closed now. Re-enter system.")
def reduce_book(book_list):
print("Book prices will be reduced by 2%")
for price in book_list:
reduction = (price * 0.98)
print("Reduction in book proice\n", book_list,reduction)
def increase_book(book_list):
print("Book prices will increase by 2%")
for price in book_list:
increase = price + (price * 0.02)
print("Increase in book price\n:", book_list,increase)
def inventory_check(book_list):
if(len(book_list)==0):
print("No books in inventory")
else:
for book in book_list:
print(book)
book_list = []
while(True):
Menu()
choice = input()
if choice == "A":
add_book(book_list)
elif choice == "B":
sell_book(book_list)
elif choice == "C":
reduce_book(book_list)
elif choice == "D":
increase_book(book_list)
elif choice == "V":
inventory_check(book_list)
elif choice == "Q":
break
else:
print("Invalid choice.")
print()
r/pythoncoding • u/rickytaylor15 • Nov 02 '19
r/pythoncoding • u/MNMApplications • Aug 19 '19
r/pythoncoding • u/lauren_nerual • May 07 '19
I'm currently enrolled in a programming class that uses Python. I'm really struggling with understanding it and how it works. For my final project I'm supposed to create a website that acts as a planner that allows a user to log in and input their upcoming homework/tests and be able to log in again and see what they have due. I have no idea how to begin or what to use.
r/pythoncoding • u/BlackMacaw • Feb 12 '19
Hey, so I'm new to coding and I heard Python was a nice programming language to get into and I'm learning lists right now but i came across this question and im not sure how to solve it
Write a function to split a list into two parts. The length of the first part is given.
def split_list(lst, len1):
""" Split list into two parts,
first part is of length len1, and rest is second part
""" ... YOUR CODE HERE ...
return lhs, rhs # lhs contains left hand part # and rhs contains right hand part now I assumed somehing like
def split_list( lst, len1):
lst = [1,2,3,4,5,6]
some type of for loop?
but from here on im not sure how to divide the list in half so if I went to check it to do a test case e.g
list = [1,2,3,4,5,6]
def split_list(l1, 2)
it would be like
lhs =[1,2,3], rhs = [4,5,6] any suggestions what to do also just how to think this through? thanks