Posts: 230
Threads: 39
Joined: Mar 2020
Nov-27-2022, 04:55 PM
(This post was last modified: Nov-27-2022, 04:56 PM by astral_travel.)
i have used this certain method in my script, dtypes,
for some reason it gives one more column info, even though this column is not visible...(nor exists to the best of my knowledge)...
here's the output:
Output: [5322 rows x 4 columns]
unnamed int64
Ticker object
Description object
Unnamed: 3 object
dtype: object
in this output - Unnamed: 3 object - where does it come from ?
Posts: 7,326
Threads: 123
Joined: Sep 2016
(Nov-27-2022, 04:55 PM)astral_travel Wrote: for some reason it gives one more column info, even though this column is not visible...(nor exists to the best of my knowledge)... It can come from empty data from file you read in.
Do df.columns will show all columns.
To clean up.
df.drop(df.filter(regex="Unname"), axis=1, inplace=True)
Posts: 230
Threads: 39
Joined: Mar 2020
(Nov-27-2022, 06:42 PM)snippsat Wrote: (Nov-27-2022, 04:55 PM)astral_travel Wrote: for some reason it gives one more column info, even though this column is not visible...(nor exists to the best of my knowledge)... It can come from empty data from file you read in.
Do df.columns will show all columns.
To clean up.
df.drop(df.filter(regex="Unname"), axis=1, inplace=True)
okay, it sure shows it, but it does not show in the file....here's the output:
Output: Index(['unnamed', 'Ticker', 'Description', 'Unnamed: 3'], dtype='object')
and attached is the file
Posts: 7,326
Threads: 123
Joined: Sep 2016
(Nov-27-2022, 08:56 PM)astral_travel Wrote: okay, it sure shows it, but it does not show in the file....here's the output: Do not need output after you have messed with it,post as sample of input .csv that you taker in.
Posts: 230
Threads: 39
Joined: Mar 2020
okay, so i attached the file...there you can clearly see there's no such column
Posts: 7,326
Threads: 123
Joined: Sep 2016
(Nov-27-2022, 10:08 PM)astral_travel Wrote: okay, so i attached the file...there you can clearly see there's no such column Don't see any file,only allstocks.csv that seems like output from Pandas.
I mean the raw file that you take in.
Posts: 230
Threads: 39
Joined: Mar 2020
(Nov-27-2022, 10:22 PM)snippsat Wrote: (Nov-27-2022, 10:08 PM)astral_travel Wrote: okay, so i attached the file...there you can clearly see there's no such column Don't see any file,only allstocks.csv that seems like output from Pandas.
I mean the raw file that you take in.
okay, here it is (i had to remove some data so it fits within the forum's limitation (250kb). but the columns's headers are in their place)
Posts: 7,326
Threads: 123
Joined: Sep 2016
If want only Ticker and Description columns,can do i like this.
import pandas as pd
df = pd.read_csv('allstocks-original.csv')
df1 = df.iloc[:, :2]
df1.to_csv('stock.csv', index=False) >>> df1.columns
Index(['Ticker', 'Description'], dtype='object')
>>>
>>> df1.head()
Ticker Description
0 A Agilent Technologies, Inc.
1 AA Alcoa Corporation
2 AAAU Goldman Sachs Physical Gold ETF Shares
3 AABB Asia Broadband, Inc.
4 AAGFF Aftermath Silver Ltd.
Posts: 230
Threads: 39
Joined: Mar 2020
Nov-28-2022, 08:06 PM
(This post was last modified: Nov-28-2022, 08:06 PM by astral_travel.)
yea that i already understood,
i've been just wondering where that fourth column came from when typing dtypes as it is not visible anywhere....
any idea ?
ah alright snippsat i just saw you already answered this, thank you !
Posts: 12,053
Threads: 488
Joined: Sep 2016
FYI: You may already be aware of this, but if not, I'd like to share.
The best (IMHO) place to get elementary stock information, much of it for free, all for a very reasonable annual fee is here: https://www.eoddata.com/
If you want intraday quotes, you can scan the robots.txt file to get the sitemap link.
Then drill down wntil you come to the URL that will give you the quote.
Ticker symbols can be downloaded, get then in the end of day data.
You can get information for the following markets:
AMEX, ASX, CFE, EUREX, FOREX, HKEX, INDEX, LIFFE, LSE, MGEX, NASDAQ, NYBOT, NYSE, OTCBB, SGX, TSX, TSXV, USMF, and WCE
Historical data, see: https://www.eoddata.com/products/historicaldata.aspx
see:
|