Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Picking a function to execute
Post: Picking a function to execute

I want to add moving averages of prices and volume of various periods of the DJIA index. The code below works: import pandas as pd mydata = pd.read_csv('djia.csv', index_col = 'Date') what_dict = {...
palladium General Coding Help 1 204 Feb-09-2021, 02:25 PM
    Thread: Problem with pandas
Post: Problem with pandas

Sample data: Output:business_name john chin elementary school sutter pub and restaurant sri thai cuisine washington bakery & restaurant brothers restaurantThe goal is to filter out which of these ...
palladium General Coding Help 0 217 Jan-08-2021, 12:54 AM
    Thread: Converting .txt to .csv file
Post: RE: Converting .txt to .csv file

(Jan-01-2021, 07:48 AM)SunWers Wrote: (Jan-01-2021, 07:41 AM)buran Wrote: can you upload sample input file? Looking at the screenshot again, it is more likely a fixed-width file. Sorry, crazy ques...
palladium General Coding Help 19 985 Jan-01-2021, 07:56 AM
    Thread: Converting .txt to .csv file
Post: RE: Converting .txt to .csv file

(Jan-01-2021, 07:31 AM)SunWers Wrote: (Jan-01-2021, 06:52 AM)palladium Wrote: Easiest way to find out is to print out the dataframe and see how many columns you get. I can't see any ';' delimiters...
palladium General Coding Help 19 985 Jan-01-2021, 07:53 AM
    Thread: Converting .txt to .csv file
Post: RE: Converting .txt to .csv file

(Jan-01-2021, 06:29 AM)SunWers Wrote: I'm thinking it's because of this part of the code with the ; Easiest way to find out is to print out the dataframe and see how many columns you get. I can't se...
palladium General Coding Help 19 985 Jan-01-2021, 06:52 AM
    Thread: How to rearrange DataFrame ?
Post: RE: How to rearrange DataFrame ?

Can you please post the code and a sample of your csv file
palladium Data Science 1 362 Jan-01-2021, 04:14 AM
    Thread: Newbie Help with Datetime formats and numPy
Post: RE: Newbie Help with Datetime formats and numPy

See this SO post: https://stackoverflow.com/questions/3191...with-numba Essentially pandas store all datetimes in datetime64[ns] format only (i.e. down to nanoseconds), but busday_count requires dat...
palladium Data Science 2 473 Dec-31-2020, 03:00 PM
    Thread: Comparing results within a list and appending to pandas dataframe
Post: RE: Comparing results within a list and appending ...

Can you post a runnable code with a subset of your data, and the complete traceback?
palladium Data Science 1 362 Dec-17-2020, 01:08 PM
    Thread: Getting the hourly average of a time series dataset
Post: RE: Getting the hourly average of a time series da...

Your time stamps have a trailing white space at the end just before the comma. After removing the trailing white spaces the error goes away.
palladium General Coding Help 10 1,591 Dec-15-2020, 12:51 PM
    Thread: Getting the hourly average of a time series dataset
Post: RE: Getting the hourly average of a time series da...

I plugged in the problematic string you pointed out into my csv file and it worked for me. Can you post the entire traceback? Also, check that your csv file is formatted like your OP post, but with...
palladium General Coding Help 10 1,591 Dec-15-2020, 09:31 AM
    Thread: Analyzing yearly expenses (CSV file) from debit card
Post: RE: Analyzing yearly expenses (CSV file) from debi...

(Dec-13-2020, 02:42 PM)Python_User Wrote: Yes I am using Excel to display the csv file. Openpyxl is only for reading Excel xlsx, xlsm, xltx and xltm files I thought? It can do formatting too: https:...
palladium Data Science 4 441 Dec-14-2020, 03:20 PM
    Thread: Analyzing yearly expenses (CSV file) from debit card
Post: RE: Analyzing yearly expenses (CSV file) from debi...

Are you trying to build a pivot table? pandas has support for them, though I must admit I haven't use it before. Formatting cells (e.g. changing fonts to bold) , assuming you are using Excel to disp...
palladium Data Science 4 441 Dec-13-2020, 02:29 PM
    Thread: How can this for loop work without : ?
Post: RE: How can this for loop work without : ?

It is called dictionary comprehension. Basically the code is roughly equivalent to: def find_all_longest_words(dirname): dict = {} for filename in os.listdir(dirname): if os.path.isfile(o...
palladium General Coding Help 1 305 Dec-13-2020, 01:19 AM
    Thread: Building a food delivery program
Post: RE: Building a food delivery program

(Dec-06-2020, 01:26 PM)ElenaPapagia Wrote: 3 - Orders Create an Order class to manage orders from customers An order should have an id, a meal_id (which is the is for the meal ordered), and a custom...
palladium Homework 2 446 Dec-12-2020, 12:00 PM
    Thread: How to run parallel command (same command -ping)
Post: RE: How to run parallel command (same command -pin...

Asyncio might be your best bet: https://docs.python.org/3/library/asyncio.html
palladium General Coding Help 3 458 Dec-12-2020, 11:04 AM
    Thread: Help with a ValueError
Post: RE: Help with a ValueError

See here: https://pandas.pydata.org/pandas-docs/ve...tchas.html and here: https://stackoverflow.com/questions/3692...em-a-any-o A little hard to give specific advice without knowing what you are try...
palladium General Coding Help 4 405 Dec-12-2020, 07:24 AM
    Thread: Input validation goes south.
Post: RE: Input validation goes south.

Relevant excerpts: def get_number_of_answers(n_o_a): try: n_o_a = int(input("Number of answers (Max 4)? ")) except ValueError: number_of_answers.clear() print("***...
palladium General Coding Help 6 558 Dec-04-2020, 02:52 AM
    Thread: Getting the hourly average of a time series dataset
Post: RE: Getting the hourly average of a time series da...

import pandas as pd from datetime import datetime import numpy as np def get_hour(string): """Gets hour from datestring""" hr = datetime.fromisoformat(string).hour return hr def get_date...
palladium General Coding Help 10 1,591 Dec-02-2020, 10:01 AM
    Thread: How to make global list inside function
Post: RE: How to make global list inside function

Line 10, try: print(userinput.choice)
palladium General Coding Help 6 554 Nov-25-2020, 10:18 AM
    Thread: Error on nested loop : Invalid syntax
Post: RE: Error on nested loop : Invalid syntax

Can you show a subset of the infinite loop, as well as the code with all the imports (what is the function distance()?) and a subset of data so that we can run the code?
palladium General Coding Help 3 463 Nov-25-2020, 10:04 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020