Skip to main content
0 votes
1 answer
36 views

KeyError when trying to ftp from NASDAQ Other Symbols

I am trying to make a program to get a list of all (or at least almost all) USA listed stocks on all exchanges. I got AI to generate the following program suggestion: import pandas as pd from ftplib ...
Shawn Duffy's user avatar
1 vote
2 answers
63 views

How to store number as a text while exporting from pandas to excel

I have a DataFrame that contains an A/C number column, where some values are longer than 15 digits. When I export the DataFrame to Excel using .to_excel(), Excel automatically converts these long ...
pritesh's user avatar
  • 21
1 vote
1 answer
48 views

How to assign int input value as column name in pandas [duplicate]

I need to take an integer input value, assign it to a variable, and then use that variable as a column name to get data from a pandas DataFrame. Data: 1 10 20 30 2 40 50 60 Steps: Assign input to ...
madhu chatim's user avatar
1 vote
0 answers
62 views

Why does DataFrame.apply() use axis=1 for rows instead of axis=0 in pandas? [duplicate]

I was reading the pandas documentation: pandas.DataFrame.apply documentation In this definition, it seems to me like the use of axis is the exact opposite of what it means in other functions? To apply ...
Jacoberu's user avatar
0 votes
0 answers
62 views

Different epoch time from the same datetime

Here is my code: import pandas as pd import datetime df = pd.DataFrame({'str_date': ['2023091004']}) df['epoch'] = pd.to_datetime(df['str_date'], format='%Y%m%d%H').astype(int) // 10**9 dt = ...
user1700890's user avatar
  • 7,798
0 votes
0 answers
48 views

entsoe-py query_imbalance_(prices|volumes) fails with ValueError: invalid literal for int(): '1,346' in parser — best fix?

I’m fetching ENTSO-E imbalance prices/volumes with entsoe-py and hit a parser crash because the <position> field contains a thousands separator comma (e.g. "1,346"), which int() can’t ...
EmmaW23's user avatar
0 votes
0 answers
100 views

How to get value of cell in dataframe

I'm new to Python, so please be lenient. I want to read the value of a single cell from a dataframe based on the selected row. I do this as below, but I get the value not when I click on a record (...
Szymon Tomtała's user avatar
1 vote
3 answers
134 views

After encoding my categorical columns in a pandas dataframe, I was left with too many columns. How can I drop some?

I am using Python with a pandas dataframe, it is a CSV of Steam games, and I have the categorical columns of publishers, developers, categories, genres, and tags, but categories, genres, and tags are ...
Luciano Elish's user avatar
3 votes
2 answers
114 views

Calculate cumulative value based on another column [duplicate]

Having this kind of pandas dataframe df = pd.DataFrame({ 'ts_diff':[0, 0, 738, 20, 29, 61, 42, 18, 62, 41, 42, 0, 0, 729, 43, 59, 42, 61, 44, 36, 61, 61, 42, 18, 62, 41, 42, 0, 0] }) ts_diff - is ...
ihtus's user avatar
  • 2,863
-5 votes
1 answer
102 views

Using for loop to find a common value for every time another common value appears

import pandas as pd a=1 b=2 c=3 for n in range(10, len(df)-1): if df.loc[n].isin([a]).any() and df.loc[n].isin([b]).any() : for x in range(0, ...
Kan's user avatar
  • 45
0 votes
0 answers
61 views

How can I keep the first occurrence of repeated values in the same column in Pandas and delete the others? [closed]

I have a DataFrame and I want to keep only the first occurrence of repeating values in the same column and delete the others. Sample data: import pandas as pd df = pd.DataFrame({ "id": [...
Wendzara's user avatar
Best practices
0 votes
7 replies
114 views

Value count accuracy

I was trying to calculate the accuracy of my roberta label and pre existing dataset label i was confused on how to operate pandas's value_counts(), i dont know how to do operations on it before, the ...
Fauzan Anggito Wicakson's user avatar
3 votes
3 answers
170 views

Filter a pandas df: per group, keep only non-null rows if we have them, else keep a single null row

Hopefully the title is reasonably intuitive, edits welcome. Say I have this dataframe: df = pd.DataFrame({'x': ['A', 'B', 'B', 'C', 'C', 'C', 'D', 'D'], 'y': [None, None, 1, 2, 3, 4,...
Hendy's user avatar
  • 10.7k
Best practices
0 votes
5 replies
170 views

What is the ideal production-grade infrastructure to deploy a Python FastAPI service for computing option Greeks (e.g., Black–Scholes)?

I am building a python service to compute Greek values using python, but I have never worked on python, and I would appreciate advice from the experienced python devs as it would help me a lot. FLOW ...
NOOB DEV's user avatar
2 votes
1 answer
112 views

Concatenate Tables Based on Column Information in Python [duplicate]

I have a dataframes pulled from a file. The variable with all these dataframe names is: Data_Tables. These dataframes all have the same columns, and I want to concatenate the dataframes based on the ...
Jon S's user avatar
  • 55

15 30 50 per page
1
2 3 4 5
19283