I’m new to Python and programming in general and I am having trouble with a website parsing project. This is the code I managed to write: What I’m trying to do and can’t find a solution to, is to add to item_list the name of the item which the url refers to. e.g. index platinum quantity R…
Tag: pandas
how to access rows of df depending on values of another column in another df
I have a df2 and a temp df that has more rows and more columns(some are common) than df2. I want to get the ‘p’col values from df2 into temp df, in the rows with compatible values between the two (see screenshot below.) so expected output would be the following df: This should not be as hard as I&…
How To Prevent Fast Execute Many Giving Truncation Error
Not sure how to reproduce this as I’m not sure what is causing the issue in the first place, however, I have the currently line of code which writes data to an SQL Server Table. However I get the following error: I have checked the sql server and see that varchar has been set to -1 which indicates that …
Extracting latest values in a Dask dataframe with non-unique index column dates
I’m quite familiar with pandas dataframes but I’m very new to Dask so I’m still trying to wrap my head around parallelizing my code. I’ve obtained my desired results using pandas and pandarallel already so what I’m trying to figure out is if I can scale up the task or speed it up…
Looping through a filtered dataframe to see if a value is in a list column
Apologies for the vague title, I’m not entirely sure how to word it more correctly. I have a DataFrame like this: Which is created with this: And the logic behind it is that each line is a customer record: they can only ever save one product at a time (which is why savedProduct has one product code) but…
Struggles with converting a DBF file to Pandas DataFrame
I’m attempting to work with the Canadian radio station DBF files made public here: https://sms-sgs.ic.gc.ca/eic/site/sms-sgs-prod.nsf/eng/h_00015.html I’d like to read specifically the fmstatio.dbf file into a Pandas DataFrame. I’ve tried the two commonly recommended DBF packages in Python. …
Python: pandas_datareader import historical stock data in euro
My aim is to get historical stock datas of different stocks from europe and us. With the function: Output: returns the historical stock data in USD. Otherwise Output: return the historical stock data in EUR. Is there a possibility to unify the currency in both cases? Answer Download EURUSD%3DX to convert your…
Calculating hamming distance in a given year
I have a following dataframe: I would like to calculate pairwise hamming distance for each pair in a given year and save it into a new dataframe. Example: (Note: I made up the numbers for the hamming distance, and I don’t actually need to Pair column) I tried something like: Answer The function pairwise…
InvalidArgumentException: invalid argument error using Selenium and Pandas scraping urls reading from a CSV
I was trying to scrape a website, where possible urls are in csv. So after reading it through for loop to call my method, where I would open the url and gonna scrape the contents of the site. But due to some reason I am unable to loop and open the urls Here is my code: Error on console I
Pandas: Sort dataframe correctly with German umlauts, upper/lowercase and numbers
I have this dataframe (all strings): I want to sort it so that German umlauts are correct, also lowercase and numbers are correct: Here is my code to generate the dataframe and result: The result is almost correct, but the numbers are sorted in the wrong order, 20 should be before 200: How can I fix the numbe…