avatarMatthew Clapham

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1238

Abstract

me Python code to retrieve Tesla stock prices from 2022 using Yahoo Finance. I want the output to be in a csv file called ‘stock_prices.csv’ The CSV file mys have a column named “Date” representing the dates and a column named “Price” representing the stock prices.”</p><p id="e110">And then the output will be:</p><figure id="f70f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4cgK5TnDtjHmV_MaFnGNCw.png"><figcaption></figcaption></figure><h1 id="df02">Step 2: Copy this code using the botton “copy code” at the top right</h1><h1 id="f854">Step 3: Paste the code in Google Colab</h1><p id="38fa">Navigate to <a href="https://colab.research.google.com/">https://colab.research.google.com/</a> . The create a new notebook by logging in using your Google account.</p><p id="0eee">This is the full code I got from Chat GPT.</p><p id="77be">But remember, you can customise the prompt to get any other stock.</p><div id="eeb1"><pre><span class="hljs-keyword">import</span> yfinance <span class="hljs-keyword">as</span> yf <span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-comment"># Define the stock symbol and the time range for which you want the data</span> sym

Options

bol = <span class="hljs-string">"TSLA"</span> start_date = <span class="hljs-string">"2022-01-01"</span> end_date = <span class="hljs-string">"2022-12-31"</span>

<span class="hljs-comment"># Fetch the stock data using Yahoo Finance</span> stock_data = yf.download(symbol, start=start_date, end=end_date)

<span class="hljs-comment"># Extract the 'Date' and 'Close' columns from the stock data</span> stock_data = stock_data[[<span class="hljs-string">'Close'</span>]].reset_index()

<span class="hljs-comment"># Rename the columns to 'Date' and 'Price'</span> stock_data.columns = [<span class="hljs-string">'Date'</span>, <span class="hljs-string">'Price'</span>]

<span class="hljs-comment"># Save the stock data to a CSV file</span> stock_data.to_csv(<span class="hljs-string">'stock_prices.csv'</span>, index=<span class="hljs-literal">False</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">"Stock data saved to 'stock_prices.csv'"</span>)</pre></div><h1 id="dbca">Step 4: Use the CSV file with the stock data</h1><p id="db5f">As simple as that!</p><figure id="4c88"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*lpNgMNRzr3oNIaAX.png"><figcaption></figcaption></figure></article></body>

LIFE: AN ABRIDGED USER’S MANUAL

Advice For My Kids As They Approach Adulthood

But since they’ll just eye-roll and ignore me, I’m sharing it with you lucky guys

Two roads diverged in a wood, and I… (Photo by Jens Lelie on Unsplash)

Obviously, when you’re 18 you know everything there is to be known. And if you’re going to take advice from anyone, it’s not going to be your parents. Unless they manage to subcontract some TikTok Illuminatus to chop it all up into 15-second goldfish bowl gobbets and somehow embed it in your algorithmic drip feed.

But anyway, they might want to read this someday. Or all of us parents on Medium could just do a big pass-the-parcel swap where we give each other’s offspring sage advice, untainted by the whiff of parental prescription. Packaged as ‘Don’t Make These 5 Dumb Generation X Mistakes’ so they can feel all superior and not condescended to.

There’s never any point in regretting past decisions in my mind. But there are some options that I maybe would like to have considered before taking certain paths in life. And then making the same damned fool mistakes in any event.

So, here goes…

1. Think very carefully before choosing to study your favorite school subject at the university

This is if university seems to be a good idea in any event. I would advise anyone, my younger self included, to put off that decision for at least a year, if not two. Or ten. But if you’re going to follow convention and pick a course at 18, put your grade-A subject to the bottom of the list, and let it fight its way back to the top if it really deserves it, after considering everything else.

Why? Because you otherwise run the risk of burning out your enthusiasm. Sure, the university-level study will open up new aspects, and dive to greater depths. But you’ve been sitting in chemistry or history or whatever class for at least five, if not ten years, depending on how core to the curriculum your chosen subject is.

Think first of all about something that your aptitude and knowledge can feed into, but that is also brand new, a fresh start. Whether that’s segueing from physics into engineering, geography into environmental science, or history into politics.

Or just pick something completely different. It will probably be harder work, to begin with, but might ultimately be more fulfilling. Me? I toyed with dropping German and instead combining Arabic with my Spanish, which would have involved a year in Alexandria. Plus having to learn a whole new language and script from scratch… I took the lazy option instead. Teenagers, eh?

2. If you do go to university, remember that you will learn more from your fellow students than your teachers

This probably doesn’t need to be said. Youngsters will -and in my mind should- probably spend as much of their time socializing as they possibly can, while devoting just enough time to their coursework so as not to get kicked out. This was one piece of my older self’s advice that I embraced wholeheartedly.

But it’s not just about the social side. There’s also so much academic and intellectual value to be gleaned from chatting with fellow students on other courses about the concepts they are discovering, and how they relate to, challenge, or suggest new pathways for ideas from completely different fields of study. Academia so often pigeonholes and overspecializes both students and above all staff.

The German word for academic subject, Fach, is also quite literally the word for pigeonhole.

That’s wrong. Knowledge comes from connecting across subjects, creating a mental mycelium that embraces the whole institution, the entire world. You will never be surrounded by so many eager, enquiring minds, with so much time to explore the universe of ideas. Grab that chance.

At this point, we skip forward a couple of years and assume that the training, studying, or bumming around of the immediate post-high school years is done and dusted and you’ve managed to get a job.

3. Buy some kind of home as soon as you possibly can

Gee, thanks for the tip, Dad! I’ll pick up a couple of yachts and a Ferrari while I’m at it, yeah? I know, I know. These days it’s quite likely to be impossible in any case until much further down the track, and until then, the fruit of my loins, you’re more than welcome to stay at home for as long as it takes for you to work out how those weird buttons on the front of the washing machine work. Ask the cat — she’s been studying it intently for years.

But once it becomes feasible, with whatever loans or guarantees that governments, parents, or grandparents might be offering at the time, do it. Get a place, however small, somewhere you’ll be able to rent it out if you move around. Because you probably will, and should. But if you spend a decade or more drifting around, exploring this wonderful world (as your old dad did), then that whole time property is probably going to be getting even more expensive and unaffordable.

This isn’t about investment, it’s about security. God knows you’re going to face enough insecurity and lack of permanence in your professional and financial life. Having your name on the deeds to a place you can call home should give you a little peace of mind, a bolthole you can shelter up in from the storms of life. And have mostly paid for before you need to start worrying too much about where the hell your pension’s going to come from.

4. Think about your whole social support network before having kids and while they’re little

It’s easy as prospective parents or when you have a toddler and a newborn to feel that you are your own self-contained family unit. That you can still go anywhere, and do anything, just as you did before, so long as there’s a ready supply of nappies available. That’s quite true, but remember that it’s a long journey with plenty of lows to go with the highs.

The more people you have around you, whether family or trusted friends, the easier and less stressful it’s going to be. And those genuinely valuable relationships take time to forge. If you pitch up in a new town with a couple of primary school-age kids in tow, you’re going to be on your own when it comes to school runs, babysitting, and all the myriad logistical arrangements of family life that somehow have to be slotted into a working schedule as well.

But it’s worth it for their sakes as well. Making new friendships is tough. Day one in a new school playground is scary. You’re still young, you still need to feel free and have the confidence to take on the world. Your kids, and their grandparents, could maybe use a bit more old-fashioned, stick-in-the-mud stability.

Perfect (Photo by Tyler Nix on Unsplash)

5. Consider schools at least in the abstract well before your kids actually start

This sounds like something the landed gentry or high-flying CEOs might do, making a downpayment to book a place at a league-topping private school before the little nipper’s even blown their first birthday candle out. That’s not what I mean. But you may find that the whole system in the region or country where you’ve settled is inevitably going to cause you grief further down the line, and not offer the flexibility to make the choices you feel are right for you and your children.

It’s easy not to realize this unless you have friends with kids who are a fair bit older and have already worked their way through the system. Everything’s always happy-clappy at kindergarten and early primary. It’s later on that the pressures build and the walls narrow in. And by the time the alarm bells ring, it’s too late to move without messing up the foundations you had so carefully laid in point 4. Do your research early.

For us the issue was language. Our kids were born in Catalonia, where there are two official languages — Spanish and Catalan. But schooling is only provided in Catalan. That means forcing kids who don’t speak the language and don’t have any backup at home, to handle the entire curriculum in their third language. Sure, it can be done, but it’s an extra hassle you don’t need, especially when combined with high-pressure pass/fail exams from eight years old. And as parents, you’re substantially excluded from the whole cultural milieu of the school and associated events. That wasn’t the only reason we ended up moving, but it played a big part.

And that’s all I have to offer for now.

At this point, it’s a case of referring back to #1 for the next generation and seeing how it goes. I appreciate that this is very much a list born of a privileged, comfortable, first-world setting. And being the first to acknowledge my family’s luck in being able to consider those options and make those choices.

I do think the philosophy they reflect is more widely relevant, though, circumstances permitting. And I hope they will be of value to someone. Maybe even my own kids if they’ll stop long enough to listen. They are very much a work in progress — I’m only just over halfway through this tortoise race of life, and would love to hear other readers’ ideas on what might come next, or how else the particular stages I mention could be approached.

Thanks for reading. Now, can you condense all that into a TikTok video for me?

Some ideas about where you might want to settle down at step #4:

Life Lessons
Teenagers
Advice and Opinion
Education
Family
Recommended from ReadMedium